Image processing method and device thereof, and storage medium
Patent Information
- Application Number
- CN202310078975.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-13
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2043-01-13
AI Technical Summary
对于这种应用场景,通过常规的空间几何处理方法即可实现,但是,该方法得到的结果是采用内外环方式表示的洞状图像轮廓,而在实际应用中,现有的支持图像轮廓展示以及操作等的系统,无法直接支持这种使用内外环方式表示的洞状图像轮廓,如果想要现有的系统能够支持洞状图像轮廓,则需要对现有系统进行较大的改动
[0057]本发明实施例至少包括以下有益效果:在根据目标物图像轮廓对待处理图像轮廓进行轮廓裁剪以得到洞状图像轮廓之后,根据洞状图像轮廓的外环轮廓和内环轮廓构造得到裁剪窗口轮廓,然后根据裁剪窗口轮廓对洞状图像轮廓进行轮廓裁剪,得到能够合并表征洞状图像轮廓的多个非洞状图像轮廓。由于得到的每个非洞状图像轮廓均可以采用与待处理图像轮廓相同的表示形式进行表示,因此能够避免采用内外环方式的表示形式进行表示,而且,由于得到的多个非洞状图像轮廓的并集能够表征该洞状图像轮廓,因此在得到多个非洞状图像轮廓之后,不仅能够达到在待处理图像轮廓中去除目标物图像轮廓的目的,并且能够在不对现有系统进行较大改动的前提下实现对洞状图像轮廓的支持。
Smart Images

Figure CN116051585B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image processing method, apparatus, and storage medium. Background Technology
[0002] Image cropping is widely used in various fields such as geographic information systems, computer graphics, and robot kinematics, and is the foundation for solving many important problems in computer graphics.
[0003] In related technologies, research on image cropping mostly focuses on cropping the portion of the image outline that lies outside the outline of the target object. However, in some applications, it's necessary to remove the target object's outline from the image outline of the target object, leaving only the portion outside the target object's outline. This can be achieved using conventional spatial geometry processing methods; however, these methods result in hole-like image outlines represented by inner and outer loops. In practical applications, existing systems that support image outline display and manipulation cannot directly support these hole-like outlines represented by inner and outer loops. Enabling existing systems to support hole-like image outlines requires significant modifications. Therefore, how to achieve support for hole-like image outlines without major modifications to existing systems is a pressing technical problem. Summary of the Invention
[0004] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.
[0005] This invention provides an image processing method, apparatus, and storage medium that can support hole-shaped image contours without making significant modifications to existing systems.
[0006] On one hand, embodiments of the present invention provide an image processing method, including the following steps:
[0007] Obtain the outline of the image to be processed and the outline of the target image, wherein the outline of the image to be processed includes the outline of the target image or intersects with the outline of the target image;
[0008] Based on the target object image contour, the image contour to be processed is cropped to obtain a hole-shaped image contour, wherein the hole-shaped image contour includes an outer ring contour and an inner ring contour;
[0009] The clipping window outline is constructed based on the outer ring outline and the inner ring outline;
[0010] The hole-shaped image contour is cropped according to the outline of the cropping window to obtain multiple non-hole-shaped image contours, wherein the union of all the non-hole-shaped image contours is used to represent the hole-shaped image contour.
[0011] On the other hand, embodiments of the present invention also provide an image processing apparatus, including:
[0012] A contour acquisition unit is used to acquire the contour of the image to be processed and the contour of the target image, wherein the contour of the image to be processed includes the contour of the target image or intersects with the contour of the target image;
[0013] The first cropping unit is used to crop the outline of the image to be processed according to the outline of the target object image to obtain a hole-shaped image outline, wherein the hole-shaped image outline includes an outer ring outline and an inner ring outline.
[0014] A contour construction unit is used to construct a clipping window contour based on the outer ring contour and the inner ring contour.
[0015] The second cropping unit is used to crop the hole-shaped image contour according to the cropping window contour to obtain multiple non-hole-shaped image contours, wherein the union of all the non-hole-shaped image contours is used to represent the hole-shaped image contour.
[0016] Optionally, the contour construction unit is further used for:
[0017] The coordinate points of the first window are determined based on the outer ring contour.
[0018] The coordinate points of the second window are determined based on the inner ring contour.
[0019] The outline of the clipping window is constructed based on the coordinates of the first window and the coordinates of the second window.
[0020] Optionally, the contour building unit is further used for:
[0021] Obtain the coordinates of all outer ring contour points in the outer ring contour;
[0022] The point with the largest vertical axis coordinate value among all the outer ring contour coordinate points is determined as the first window coordinate point.
[0023] Optionally, the contour building unit is further used for:
[0024] Obtain the coordinates of all inner ring contour points in the inner ring contour;
[0025] The center point of the inner ring contour is determined based on all the coordinate points of the inner ring contour.
[0026] The center point is determined as the coordinate point of the second window.
[0027] Optionally, the contour building unit is further used for:
[0028] Calculate the average of the horizontal axis coordinates of all the coordinates of the inner ring contour to obtain the horizontal axis coordinate of the center point;
[0029] Calculate the average of the ordinate values of all the coordinate points of the inner ring contour to obtain the ordinate value of the center point;
[0030] The center point of the inner ring profile is determined based on the horizontal axis coordinate value and the vertical axis coordinate value of the center point.
[0031] Optionally, the number of inner ring contours is multiple, and the number of second window coordinate points determined based on the multiple inner ring contours is multiple; the contour construction unit is further used for:
[0032] Sort the multiple second window coordinate points in ascending order of their horizontal axis coordinate values to obtain multiple candidate window coordinate points after sorting.
[0033] Multiple clipping window outlines are constructed based on the coordinates of the first window and the coordinates of each pair of adjacent candidate windows.
[0034] Optionally, the contour building unit is further used for:
[0035] The upper boundary of each cropping window is determined based on the coordinates of the first window.
[0036] For each pair of adjacent candidate window coordinates, the left boundary of the current cropping window is determined by the smaller horizontal axis coordinate value, the right boundary of the current cropping window is determined by the larger horizontal axis coordinate value, and the lower boundary of the current cropping window is determined by the smaller vertical axis coordinate value.
[0037] Multiple clipping window outlines are constructed based on the upper boundary, the left boundary, the right boundary, and the lower boundary.
[0038] Optionally, the number of cropping window outlines is multiple, and the second cropping unit is further used for:
[0039] The hole-shaped image outline is intersected and cropped with the outline of each cropping window to obtain multiple intersecting cropping results;
[0040] The outline of the hole-shaped image is cropped by all the intersecting cropping results to obtain the outline cropping result;
[0041] The contour cropping results and all the intersection cropping results are summarized to obtain multiple non-hole image contours.
[0042] Optionally, the second cutting unit is further configured to:
[0043] Perform contour merging on all the intersecting clipping results to obtain the contour merging result;
[0044] The contour of the hole-shaped image is combined with the contour merging result, and then the contour is cropped to obtain the contour cropping result.
[0045] Optionally, the number of target object image outlines is multiple, and the first cropping unit is further configured to:
[0046] The outline of the image to be processed is cropped by the outline of the current target image to obtain the cropped image outline.
[0047] The cropped image outline is cropped along with the next target image outline until all target image outlines are cropped, resulting in a hole-shaped image outline.
[0048] Optionally, the contour acquisition unit is further configured to:
[0049] Obtain the outline of the image to be processed;
[0050] Spatial indexing is performed on the image contour to be processed to obtain the image contour of the target object.
[0051] On the other hand, embodiments of the present invention also provide an image processing apparatus, including:
[0052] At least one processor;
[0053] At least one memory for storing at least one program;
[0054] The image processing method as described above is implemented when at least one of the programs is executed by at least one of the processors.
[0055] On the other hand, embodiments of the present invention also provide a computer-readable storage medium storing a processor-executable computer program, which, when executed by a processor, is used to implement the image processing method as described above.
[0056] On the other hand, embodiments of the present invention also provide a computer program product, including a computer program or computer instructions, the computer program or computer instructions being stored in a computer-readable storage medium, a processor of an image processing apparatus reading the computer program or computer instructions from the computer-readable storage medium, the processor executing the computer program or computer instructions, causing the image processing apparatus to perform the image processing method as described above.
[0057] The embodiments of the present invention include at least the following beneficial effects: After cropping the contour of the image to be processed based on the contour of the target object image to obtain a hole-shaped image contour, a cropping window contour is constructed based on the outer ring contour and inner ring contour of the hole-shaped image contour. Then, the hole-shaped image contour is cropped based on the cropping window contour to obtain multiple non-hole-shaped image contours that can be merged to represent the hole-shaped image contour. Since each obtained non-hole-shaped image contour can be represented using the same representation form as the image contour to be processed, the use of inner and outer ring representation forms can be avoided. Moreover, since the union of the multiple obtained non-hole-shaped image contours can represent the hole-shaped image contour, after obtaining multiple non-hole-shaped image contours, not only can the purpose of removing the target object image contour from the image contour to be processed be achieved, but support for hole-shaped image contours can also be realized without making significant modifications to the existing system.
[0058] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description
[0059] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation on the technical solutions of the present invention.
[0060] Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present invention;
[0061] Figure 2 This is a schematic diagram of an application scenario provided by an embodiment of the present invention;
[0062] Figure 3 This is a schematic diagram of another implementation environment provided by an embodiment of the present invention;
[0063] Figure 4 This is a schematic diagram of another application scenario provided by an embodiment of the present invention;
[0064] Figure 5 This is a flowchart of an image processing method provided in an embodiment of the present invention;
[0065] Figure 6 This is a schematic diagram illustrating the relationship between the outline of the image to be processed and the outline of the target object image provided in an embodiment of the present invention;
[0066] Figure 7 This is a schematic diagram illustrating the process of obtaining the outline of a hole-shaped image provided in an embodiment of the present invention;
[0067] Figure 8 This is a schematic diagram illustrating the process of obtaining the outline of the clipping window provided in an embodiment of the present invention;
[0068] Figure 9 This is a schematic diagram illustrating the process of cropping the outline of a hole-shaped image based on the outline of a cropping window, as provided in an embodiment of the present invention.
[0069] Figure 10 This is a flowchart illustrating the principle of an image processing method provided in a specific example of the present invention;
[0070] Figure 11 This is a schematic diagram of the process of cropping the outline of the image to be processed based on the outline of the target object image, provided by an embodiment of the present invention.
[0071] Figure 12 This is a flowchart of the steps of an image processing method provided in a specific example of the present invention;
[0072] Figure 13 This is a flowchart illustrating the steps for obtaining the outline of a hole-shaped image, provided in a specific example of the present invention.
[0073] Figure 14 This is a flowchart illustrating the steps of constructing a clipping window outline, provided in a specific example of the present invention.
[0074] Figure 15 This is a flowchart of the steps for obtaining a non-hole-shaped image contour provided by a specific example of the present invention;
[0075] Figure 16 This is a schematic diagram of an image processing device provided in an embodiment of the present invention;
[0076] Figure 17 This is a schematic diagram of another image processing device provided in an embodiment of the present invention. Detailed Implementation
[0077] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. The described embodiments should not be considered as limitations on the present invention, and all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the present invention.
[0078] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0079] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0080] Before providing a further detailed description of the embodiments of the present invention, the nouns and terms involved in the embodiments of the present invention will be explained, and the nouns and terms involved in the embodiments of the present invention shall be interpreted as follows.
[0081] 1) Image contour refers to the area studied in various fields such as geographic information systems, computer graphics, and robot kinematics. It can generally be a polygon represented by a set of coordinate points.
[0082] 2) The outline of the target object image refers to the area that is to be removed from the research area in various fields such as geographic information systems, computer graphics, and robot kinematics. It can generally be a polygon represented by a set of coordinate points.
[0083] 3) Hole-shaped image contours refer to the remaining part of the area studied in various fields such as geographic information systems, computer graphics, and robot kinematics after removing the image contours of the target object. Generally, it can be a polygon represented by inner and outer rings. Both the inner and outer rings can be polygons represented by sets of coordinate points. The outer ring represents the outer contour of the polygon, and the inner ring represents the contour of each hole inside the polygon. There can be multiple inner rings.
[0084] 4) Multi-contour image, which consists of multiple sub-image contours. Each sub-image contour is a contour represented by a set of coordinate points, and there is no intersection between the sub-image contours.
[0085] In related technologies, research on image cropping mostly focuses on cropping the portion of the image outline that lies outside the outline of the target object. However, in some applications, it's necessary to remove the target object's outline from the image outline, leaving only the portion outside the target object's outline. For example, for a research area (i.e., the image outline to be processed) that can be represented by a series of coordinate points, it's necessary to remove the outlines of targets such as lakes, roads, and parks within that area. This can be achieved using conventional spatial geometry processing methods. However, the results obtained using these methods are represented in computers as hole-like image outlines with inner and outer loops. This inner and outer loop representation of hole-like image outlines differs significantly from the coordinate point set representation of image outlines originally used by computers. In practical applications, existing systems that support image contour display and operation cannot directly support hole-shaped image contours represented by inner and outer rings. If existing systems are to support hole-shaped image contours represented by inner and outer rings, significant modifications are required. This not only requires resolving compatibility issues with image contours represented by coordinate point sets, but also necessitates readjusting or developing numerous existing related task processing workflows and tools. Therefore, the cost of such modifications is extremely high.
[0086] To support hole-shaped image contours without significant modifications to existing systems, embodiments of the present invention provide an image processing method, an image processing apparatus, a computer-readable storage medium, and a computer program product. After cropping the contour of the image to be processed based on the contour of the target object image to obtain a hole-shaped image contour, a cropping window contour is constructed based on the outer and inner ring contours of the hole-shaped image contour. Then, the hole-shaped image contour is cropped based on the cropping window contour to obtain multiple non-hole-shaped image contours that can be merged to represent the hole-shaped image contour. Since each obtained non-hole-shaped image contour can be represented using the same representation as the image to be processed, the use of inner and outer ring representations can be avoided. Furthermore, since the union of the multiple obtained non-hole-shaped image contours can represent the hole-shaped image contour, obtaining multiple non-hole-shaped image contours not only achieves the goal of removing the target object image contour from the image to be processed contour, but also enables support for hole-shaped image contours without significant modifications to existing systems.
[0087] Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present invention. (Refer to...) Figure 1The implementation environment includes a user terminal 101 and a data processing server 102, which are directly or indirectly connected via wired or wireless communication. The user terminal 101 and the data processing server 102 can be nodes in a blockchain, but this embodiment does not specifically limit their presence.
[0088] User terminal 101 may include, but is not limited to, smartphones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. Optionally, user terminal 101 may be equipped with an image processing client, through which the user can input the outline of the image to be processed and the outline of the target object image provided, and can send the outline of the image to be processed and the outline of the target object image to the data processing server 102 for image processing.
[0089] The data processing server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0090] The data processing server 102 has at least the functions of cropping image contours, constructing cropping window contours, and cropping hole-shaped image contours using cropping window contours. For example, after obtaining the image contour to be processed and the target image contour, it can crop the image contour to be processed based on the target image contour to obtain a hole-shaped image contour. Then, it can construct a cropping window contour based on the outer ring contour and inner ring contour of the hole-shaped image contour. Finally, it can crop the hole-shaped image contour based on the cropping window contour to obtain multiple non-hole-shaped image contours.
[0091] Reference Figure 2As shown, in one application scenario, assume that user terminal 101 is a computer and has an image processing client installed. In response to the user inputting the outline of the image to be processed and the outline of the target object image through the image processing client in user terminal 101, user terminal 101 sends the outline of the image to be processed and the outline of the target object image to data processing server 102. In response to receiving the outline of the image to be processed and the outline of the target object image sent by user terminal 101, data processing server 102 performs outline clipping on the outline of the image to be processed according to the target object image outline, obtaining a hole-shaped image outline including an outer ring outline and an inner ring outline. Then, based on the outer ring outline and inner ring outline of the hole-shaped image outline, a clipping window outline is constructed. Next, the hole-shaped image outline is clipped according to the clipping window outline to obtain multiple non-hole-shaped image outlines. The union of all these non-hole-shaped image outlines can be used to represent the hole-shaped image outline. After data processing server 102 obtains these non-hole-shaped image outlines, data processing server 102 sends these non-hole-shaped image outlines to user terminal 101 for display.
[0092] Figure 3 This is a schematic diagram of another implementation environment provided by an embodiment of the present invention. (Refer to...) Figure 3 The implementation environment includes an application server 301 and a processing server 302, which are directly or indirectly connected via wired or wireless communication. The application server 301 and the processing server 302 can be nodes in a blockchain, but this embodiment does not specifically limit their presence.
[0093] Application server 301 and processing server 302 can both be independent physical servers, or server clusters or distributed systems composed of multiple physical servers. They can also be cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN networks, and big data and artificial intelligence platforms.
[0094] Application server 301 has at least the functions of maintaining the normal operation of the system and saving the data information required during system operation, while processing server 302 has at least the functions of processing the saved data information during system operation. For example, application server 301 can save the image information required during system operation, while processing server 302 can call the image information in application server 301 during system operation. For example, it can obtain the outline of the image to be processed and the outline of the target object image from application server 301, and then perform outline clipping on the outline of the image to be processed according to the outline of the target object image to obtain a hole-shaped image outline. Then, it constructs a clipping window outline according to the outer ring outline and inner ring outline of the hole-shaped image outline, and performs outline clipping on the hole-shaped image outline according to the clipping window outline to obtain multiple non-hole-shaped image outlines.
[0095] Reference Figure 4 As shown, in another application scenario, assume that application server 301 is the server running a map application system, and application server 301 stores the map data required for the operation of the map application system, while processing server 302 is the server in the map application system used to process the map data. During the operation of the map application system, processing server 302 obtains the image contour to be processed from application server 301, and determines the target object image contour within the image contour to be processed; in response to obtaining the image contour to be processed and the target object image contour, processing server 302 performs contour clipping on the image contour to be processed based on the target object image contour, obtaining a hole-shaped image contour including an outer ring contour and an inner ring contour, and then constructs a clipping window contour based on the outer ring contour and inner ring contour of the hole-shaped image contour. Next, it performs contour clipping on the hole-shaped image contour based on the clipping window contour to obtain multiple non-hole-shaped image contours, where the union of all these non-hole-shaped image contours can be used to represent the hole-shaped image contour. After processing server 302 obtains these non-hole-shaped image contours, processing server 302 sends these non-hole-shaped image contours to application server 301 for subsequent data processing.
[0096] It should be noted that in various specific embodiments of the present invention, when processing data related to the characteristics of a target object (such as a user) or a set of attribute information is required, the target object's permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of the present invention need to obtain the target object's attribute information, separate permission or consent from the target object will be obtained through pop-ups or redirection to a confirmation page. Only after obtaining the target object's separate permission or consent will the necessary target object-related data for the normal operation of the embodiments of the present invention be obtained.
[0097] Figure 5 This is a flowchart of an image processing method provided in an embodiment of the present invention. This image processing method can be executed by a server, or jointly by a terminal and a server. In this embodiment, the method is described using an example of execution by a server. (Refer to...) Figure 5 The image processing method may include, but is not limited to, steps 510 to 540.
[0098] Step 510: Obtain the contour of the image to be processed and the contour of the target image, wherein the contour of the image to be processed contains the contour of the target image or intersects with the contour of the target image.
[0099] In this step, the outline of the image to be processed and the outline of the target object image can be input by the user or obtained from a server used to store data; no specific limitation is made here. The outline of the target object image can be specified by the user in the outline of the image to be processed, or it can be determined in the outline of the image to be processed using spatial indexing methods such as QT trees; no specific limitation is made here. QT trees can automatically and effectively organize and manage objects that inherit from the QObject class. Each object inheriting from the QObject class can manage its subclass objects through its object list (QObjectList). When a user creates a sub-object, its object list will update the sub-object information accordingly. In the QT tree, each object stores pointers to all its sub-objects and also stores a pointer to its parent object. Therefore, by using QT trees for spatial indexing, the outline of the target object image can be effectively obtained from the outline of the image to be processed, so that subsequent steps can use the target object image outline to perform outline cropping on the outline of the image to be processed.
[0100] In one possible implementation, both the image contour to be processed and the target image contour can be contours of arbitrary shapes. For example, the image contour to be processed and the target image contour can be contours of different shapes such as polygons, circles, and ellipses, without specific limitations. In one embodiment, both the image contour to be processed and the target image contour can be represented in the form of a set of coordinate points. For example, the image contour to be processed can be represented as {(x... a1 ,y a1 ),(x a2 ,y a2 ),……,(x an ,y an The outline of the target object image can be represented as {(x)}. b1 ,y b1 ),(x b2 ,y b2 ),……,(x bn ,y bn )}, where (x a1 ,ya1 ), (x a2 ,y a2 ) and (x an ,y an ), etc., are the coordinates of the points on the contour of the image to be processed, (x b1 ,y b1 ), (x b2 ,y b2 ) and (x bn ,y bn (e.g., ) are coordinate points on the outline of the target object image.
[0101] In one possible implementation, the spatial relationship between the contour of the image to be processed and the contour of the target image can be an inclusion relationship or an intersection relationship, without being specifically limited here. For example Figure 6 As shown, in Figure 6 In the process, there are multiple target object image contours, including a first target object image contour 620, a second target object image contour 630, and a third target object image contour 640. The image contour 610 to be processed forms an inclusion relationship with the first target object image contour 620 and the second target object image contour 630, that is, the image contour 610 to be processed contains the first target object image contour 620 and the second target object image contour 630. The image contour 610 to be processed and the third target object image contour 640 form an intersection relationship, that is, the image contour 610 to be processed intersects with the third target object image contour 640.
[0102] In one possible implementation, when acquiring the outline of the image to be processed and the outline of the target image, the outline of the image to be processed can be acquired first, and then spatial indexing can be performed on the outline of the image to be processed to obtain the outline of the target image. In one embodiment, before performing spatial indexing on the outline of the image to be processed, image recognition can be performed on the image to be processed corresponding to the outline of the image to be processed to identify the target image in the image to be processed, and a spatial index value can be marked for the target image in the image to be processed. When it is necessary to perform spatial indexing on the outline of the image to be processed to obtain the outline of the target image, indexing can be performed on the outline of the image to be processed according to the pre-marked spatial index value to obtain the outline of the target image in the outline of the image to be processed or the outline of the target image intersecting with the outline of the image to be processed.
[0103] Step 520: Based on the target object image contour, perform contour cropping on the image to be processed to obtain the hole-shaped image contour, wherein the hole-shaped image contour includes an outer ring contour and an inner ring contour.
[0104] In this step, since the outline of the image to be processed and the outline of the target image are obtained in step 510, the outline of the image to be processed can be cropped according to the outline of the target image. The outline of the target image is removed from the outline of the image to be processed, resulting in a hole-shaped image outline including an outer ring outline and an inner ring outline. This allows subsequent steps to use the outer ring outline and inner ring outline of the hole-shaped image outline to construct a cropping window outline to achieve cropping processing of the hole-shaped image outline.
[0105] In one possible implementation, a spatial clipping operation can be used to clip the outline of the image to be processed to the outline of the target image, thereby obtaining a hole-shaped image outline that does not include the outline of the target image. The spatial clipping operation is a type of spatial geometric operation; clipping outline a to outline b results in outline c, which does not include the intersection of outlines a and b. After clipping the outline of the image to be processed to the outline of the target image, a hole-shaped image outline including an outer ring outline and an inner ring outline can be obtained. The outer ring outline refers to the outer contour of the hole-shaped image outline, and the inner ring outline refers to the hole outline inside the hole-shaped image outline. Both the outer and inner ring outlines of the hole-shaped image outline can be represented as a set of coordinate points.
[0106] In one possible implementation, when there are multiple target image contours, in the process of cropping the image contour to be processed based on the target image contours to obtain the hole-shaped image contour, the image contour to be processed can first be cropped with the current target image contour to obtain a cropped image contour. Then, the cropped image contour can be cropped with the next target image contour until all target image contours have been cropped to obtain the hole-shaped image contour. Where there are multiple target image contours, these target image contours can be formed into a set. Then, each target image contour in this set is traversed. For the current target image contour, the image contour to be processed is cropped with it to obtain the current cropped image contour. Then, the current cropped image contour is used as the object for the next contour cropping with another target image contour. These steps are repeated until all target image contours in this set have been traversed, achieving spatial iterative cropping of the image contour to be processed with all target image contours, resulting in a hole-shaped image contour including an outer ring contour and an inner ring contour.
[0107] The process of obtaining the outline of a hole-shaped image is illustrated below with a specific example.
[0108] For example Figure 7 As shown, assuming the elliptical contour represents the contour of the target image and the rectangular contour with a missing corner represents the contour of the image to be processed, in... Figure 7The left-hand image shows the outline of the image to be processed and the outlines of multiple target image objects in its spatial range. The outline of the image to be processed and these target image outlines exhibit intersecting or containing relationships in space. By sequentially performing spatial iterative cropping operations on the outline of the image to be processed and each of the target image outlines, the following can be obtained: Figure 7 The image on the right shows a hole-like image outline, which can be represented in a computer using inner and outer rings, such as... Figure 7 As shown in the right-hand figure, the hole-shaped image contour uses one outer ring contour (solid line contour) to represent its outer contour, and four inner ring contours (dashed line contours) to represent the contours corresponding to the target image contours inside it.
[0109] Step 530: Construct the clipping window outline based on the outer ring outline and the inner ring outline.
[0110] In this step, since the hole-shaped image contour, including the outer ring contour and the inner ring contour, was obtained in step 520, a clipping window contour can be constructed based on the outer ring contour and the inner ring contour of the hole-shaped image contour. This allows subsequent steps to use the clipping window contour to clip the hole-shaped image contour to obtain multiple non-hole-shaped image contours that do not contain the target object image contour.
[0111] In one possible implementation, when constructing the clipping window outline based on the outer ring outline and the inner ring outline, the first window coordinate point can be determined first based on the outer ring outline, then the second window coordinate point can be determined based on the inner ring outline, and finally the clipping window outline can be constructed based on the first and second window coordinate points. When determining the first window coordinate point based on the outer ring outline, any coordinate point within the outer ring outline can be used as the first window coordinate point; no specific limitation is made here. Similarly, when determining the second window coordinate point based on the inner ring outline, any coordinate point within the inner ring outline can be used as the second window coordinate point, or the center point of the inner ring outline can be used as the second window coordinate point; no specific limitation is made here. When constructing the clipping window outline based on the first and second window coordinate points, it is only necessary to ensure that both the first and second window coordinate points are on the clipping window outline. The specific shape of the clipping window outline is not limited here; it can be any shape, such as a polygon, circle, ellipse, or other shapes; no specific limitation is made here.
[0112] In one possible implementation, when determining the coordinate point of the first window based on the outer ring contour, all coordinate points of the outer ring contour can be obtained first, and then the coordinate point with the largest ordinate value among all the outer ring contour coordinate points can be determined as the coordinate point of the first window. Since the outer ring contour can be represented as a set of coordinate points, the set of coordinate points of the outer ring contour can be traversed to obtain the coordinate point with the largest ordinate value. If there are multiple coordinate points with the largest ordinate value, one of these coordinate points can be arbitrarily selected, and then this selected coordinate point with the largest ordinate value can be determined as the coordinate point of the first window.
[0113] In one possible implementation, when determining the coordinate points of the second window based on the inner ring contour, all coordinate points of the inner ring contour can be obtained first. Then, the center point of the inner ring contour is determined based on all the coordinate points, and the center point is then used as the coordinate point of the second window. Since the inner ring contour can be represented as a set of coordinate points, all coordinate points of the inner ring contour can be obtained, and the center point of the inner ring contour can be determined based on these coordinate points, and then used as the coordinate point of the second window. In one embodiment, during the process of determining the center point of the inner ring contour based on all the coordinate points of the inner ring contour, the average of the horizontal axis coordinates of all the inner ring contour coordinate points can be calculated first to obtain the horizontal axis coordinate value of the center point. Then, the average of the vertical axis coordinates of all the inner ring contour coordinate points can be calculated to obtain the vertical axis coordinate value of the center point. Finally, the center point of the inner ring contour is determined based on the horizontal and vertical coordinate values of the center point.
[0114] In one possible implementation, when there are multiple inner ring contours and multiple second window coordinate points determined based on these inner ring contours, when constructing the clipping window contour based on the first and second window coordinate points, the multiple second window coordinate points can be first sorted in ascending order of their horizontal axis coordinate values to obtain multiple candidate window coordinate points. Then, multiple clipping window contours are constructed based on the first window coordinate points and each pair of adjacent candidate window coordinate points. Specifically, in constructing multiple clipping window contours based on the first window coordinate points and each pair of adjacent candidate window coordinate points, the vertical axis coordinate value of the first window coordinate points can be used as the upper boundary of the vertical axis coordinates. Then, the clipping window contours are constructed based on the upper boundary of the vertical axis coordinates and each pair of adjacent candidate window coordinate points. That is, when there are multiple sets of adjacent pairs of candidate window coordinate points, multiple clipping window contours can be obtained. The clipping window contour uses the upper boundary of the vertical axis coordinates as its upper boundary, and each pair of adjacent candidate window coordinate points lies on the same clipping window contour. Furthermore, adjacent clipping window contours do not intersect.
[0115] In one possible implementation, when constructing multiple clipping window outlines based on the coordinates of the first window and the coordinates of each pair of adjacent candidate windows, the upper boundary of each clipping window can be determined first based on the coordinates of the first window. For example, the vertical coordinate value of the first window can be obtained first, and then used as the upper boundary of each clipping window. Then, for each pair of adjacent candidate window coordinates, the left boundary of the current clipping window is determined based on the smaller horizontal coordinate value, and the right boundary of the current clipping window is determined based on the larger horizontal coordinate value. The lower boundary of the current clipping window is determined based on the smaller of the vertical axis coordinate values. For example, assuming that the coordinates of two adjacent candidate windows are (x1, y1) and (x2, y2), where x2 is greater than x1 and y1 is greater than y2, then the left boundary of the current clipping window can be determined as x1, the right boundary as x2, and the lower boundary as y2. After obtaining the upper, left, right, and lower boundaries of each clipping window, multiple clipping window outlines can be constructed based on these boundaries. It should be noted that the upper boundary of the clipping window is used to limit the maximum ordinate value of the coordinate points contained in the clipping window to not be greater than the ordinate value corresponding to the upper boundary. The lower boundary of the clipping window is used to limit the minimum ordinate value of the coordinate points contained in the clipping window to not be less than the ordinate value corresponding to the lower boundary. The left boundary of the clipping window is used to limit the minimum x-axis coordinate value of the coordinate points contained in the clipping window to not be less than the x-axis coordinate value corresponding to the left boundary. The right boundary of the clipping window is used to limit the maximum x-axis coordinate value of the coordinate points contained in the clipping window to not be greater than the x-axis coordinate value corresponding to the right boundary. The upper, left, right and lower boundaries of the clipping window do not restrict the specific shape of the clipping window. That is to say, within the range of the upper, left, right and lower boundaries, the outline of the clipping window (i.e. the clipping window outline) can be different shapes such as polygons, circles, ellipses, etc., without specific limitations here.
[0116] The following example illustrates the process of obtaining the outline of the clipping window.
[0117] For example Figure 8 As shown, after obtaining the hole-shaped image contour including the outer ring contour and the inner ring contour, the outer ring contour coordinate point with the largest vertical axis coordinate value can be determined from all the outer ring contour coordinate points, and this outer ring contour coordinate point can be used as the first window coordinate point, for example... Figure 8In the left-hand image, the first window coordinate point is 810. Then, for each inner ring contour, the average of the horizontal and vertical coordinate values of all inner ring contour coordinate points is calculated to obtain the horizontal and vertical coordinate values of the center point of each inner ring contour. Based on these values, the center point of each inner ring contour is determined. After obtaining the center point of each inner ring contour, the center point is used as the second window coordinate point, for example... Figure 8 The second window coordinate point 820 is shown in the left-hand image. Next, all second window coordinate points 820 are sorted in ascending order of their horizontal axis coordinate values. The vertical axis coordinate value of the first window coordinate point 810 is used as the upper boundary of the vertical axis. Then, multiple clipping window outlines are constructed based on the upper boundary of the vertical axis and each pair of adjacent second window coordinate points 820 after sorting. For example... Figure 8 The cropping window outline is 830 in the image on the right.
[0118] Step 540: Crop the hole-shaped image contour according to the cropping window contour to obtain multiple non-hole-shaped image contours. The union of all non-hole-shaped image contours is used to represent the hole-shaped image contour.
[0119] In this step, since the hole-shaped image contour was obtained in step 520 and the clipping window contour was obtained in step 530, the hole-shaped image contour can be clipped according to the clipping window contour to obtain multiple non-hole-shaped image contours that can be merged to represent the hole-shaped image contour. For example, after clipping the hole-shaped image contour according to the clipping window contour, at least the part of the hole-shaped image contour where the clipping window contour is located and other parts other than the clipping window contour can be obtained. These parts are all non-hole-shaped image contours, and the union of all these non-hole-shaped image contours can be used to represent the original hole-shaped image contour. In one embodiment, each non-hole-shaped image contour obtained can be represented in the same way as the image contour to be processed (i.e., it can be represented in the form of a set of coordinate points). Therefore, it is possible to avoid using an inner and outer ring representation to represent the hole-shaped image contour. Moreover, the union of all the obtained non-hole-shaped image contours can characterize the hole-shaped image contour. Therefore, after obtaining multiple non-hole-shaped image contours, it is possible not only to remove the target image contour from the image contour to be processed, but also to support the hole-shaped image contour without making significant changes to the existing system.
[0120] In one possible implementation, when there are multiple cropping window outlines, during the process of cropping the hole-shaped image outline based on the cropping window outlines, the hole-shaped image outline can first be intersected with each cropping window outline to obtain multiple intersecting cropping results. Then, the hole-shaped image outline is cropped with all the intersecting cropping results to obtain the outline cropping result. Finally, the outline cropping result and all the intersecting cropping results are summarized to obtain multiple non-hole-shaped image outlines. Specifically, when cropping the hole-shaped image outline with all the intersecting cropping results to obtain the outline cropping result, the outlines of all the intersecting cropping results can first be merged to obtain the merged outline result. Then, the hole-shaped image outline is cropped with the merged outline result to obtain the outline cropping result.
[0121] The following example illustrates the process of cropping the outline of a hole-shaped image based on the outline of the cropping window.
[0122] For example Figure 9 As shown, after obtaining the hole-shaped image outline and multiple cropping window outlines, each cropping window outline can be spatially intersected with the hole-shaped image outline to obtain the following results: Figure 9 The left-hand diagram shows multiple intersecting clipping results 910. Spatial intersection is a spatial geometric operation; the result of spatially intersecting contour a and contour b is the intersection of contour a and contour b. After obtaining multiple intersecting clipping results 910, a spatial merging operation is performed on these results to obtain a contour merging result. Spatial merging is a spatial geometric operation; the result of spatially merging contour a and contour b is the union of contour a and contour b. After obtaining the contour merging result, a spatial clipping operation is then performed between the contour merging result and the original hole-shaped image contour to obtain the result shown below. Figure 9 The middle figure shows the outline clipping result 920. At this point, since we have obtained the outline clipping result 920 and multiple intersecting clipping results 910, we can summarize the outline clipping result 920 and all the intersecting clipping results 910 to obtain the following: Figure 9 The right-hand image shows multiple non-hole-shaped image contours. Using the method of this embodiment, a hole-shaped image contour obtained after removing the target object image contour through contour cutting can be transformed into a multi-contour image including multiple non-hole-shaped image contours, for example... Figure 9 As shown in the figure on the right, the multi-contour image includes three non-hole-shaped image contours obtained by cutting through the clipping window contours (i.e., intersecting clipping result 910) and one remaining non-hole-shaped image contour after cutting through the clipping window contours (i.e., contour clipping result 920).
[0123] In this embodiment, the image processing method, including steps 510 to 540, after cropping the contour of the image to be processed based on the contour of the target object image to obtain the hole-shaped image contour, firstly, a cropping window contour is constructed based on the outer and inner ring contours of the hole-shaped image contour. Then, the hole-shaped image contour is cropped based on the cropping window contour to obtain multiple non-hole-shaped image contours that can be merged to represent the hole-shaped image contour. Since each obtained non-hole-shaped image contour can be represented using the same representation as the image contour to be processed, the use of inner and outer ring representations can be avoided. Moreover, since the union of the multiple obtained non-hole-shaped image contours can represent the hole-shaped image contour, after obtaining multiple non-hole-shaped image contours, not only can the purpose of removing the target object image contour from the image contour to be processed be achieved, but support for hole-shaped image contours can also be achieved without making significant modifications to the existing system. Furthermore, in the method of this embodiment, the order of magnitude of the non-hole-shaped image contours obtained by cutting the hole-shaped image contour is the same as the order of magnitude of the inner ring contour in the hole-shaped image contour, for example... Figure 9 In this embodiment, there are four inner ring contours and four non-hole image contours. Therefore, the method in this embodiment will not cause excessive data storage pressure due to the fragmented non-hole image contours and the large number of coordinate points obtained after cutting. The method in this embodiment is highly versatile and can be used to remove various elements that affect the study within the research scope. For example, when the research scope is map data of a certain area, the various elements that can be removed that affect the study may include lakes, roads, parks, and custom target object contours.
[0124] The image processing method provided in the embodiments of the present invention will be described in detail below with specific examples.
[0125] like Figure 10 As shown, Figure 10 This is a flowchart illustrating the principle of an image processing method provided as a specific example. When applying this image processing method to a real-world scenario, the outline of the image to be processed and the outline of the target object image can be used as input data. These outlines are input into an image processing device equipped with this method. The image processing device performs contour cropping and other processing on the outline of the image to be processed based on the target object image outline, and outputs multiple non-hole-shaped image outlines obtained by removing the target object image outline from the outline of the image to be processed. The process of the image processing device performing contour cropping and other processing on the outline of the image to be processed based on the target object image outline can be seen in [example description missing]. Figure 11 As shown. In Figure 11 The top left image shows the outline of the image to be processed. Figure 11 The upper right image shows the outline of the target object. Figure 11The lower left image shows the spatial relationship between the outline of the image to be processed and the outline of the target image. When using... Figure 11 The outline of the image to be processed in the upper left of the image and Figure 11 The target object image outline in the upper right image is used as input data. After being input into an image processing device equipped with the image processing method of this embodiment, the image processing device will output as follows: Figure 11 The multi-contour image shown in the lower right of the middle image, in Figure 11 The multi-contour image shown in the lower right of the image includes two non-hole image contours. Neither of these two non-hole image contours contains the target object image contour, and the two non-hole image contours do not intersect. In other words, the result output by the image processing device achieves the effect of removing the target object image contour from the image contour to be processed.
[0126] like Figure 12 As shown, Figure 12 This is a flowchart illustrating the steps of an image processing method as a specific example. Figure 12 The image processing method can be mainly divided into three stages: data preprocessing, cropping window construction, and image contour cutting. Data preprocessing can crop the target object image contour from the contour of the image to be processed, obtaining a hole-shaped image contour. Cropping window construction can construct a cropping window contour based on the outer and inner ring contours of the hole-shaped image contour. Image contour cutting can perform contour cropping on the hole-shaped image contour based on the cropping window contour to obtain multiple non-hole-shaped image contours. Specifically, the image processing method may include steps 1210 to 1280.
[0127] Step 1210: Determine the target object image contour in the contour of the image to be processed by spatial indexing;
[0128] Step 1220: Spatial cropping of the image contour to be processed and the target object image contour to obtain the hole-shaped image contour;
[0129] Step 1230: Determine the highest point of the vertical axis of the outer ring contour in the hole-shaped image contour and the center point of each inner ring contour in the hole-shaped image contour as the positioning points;
[0130] Step 1240: Determine the upper boundary of the clipping window outline based on the positioning points in the outer ring outline, and determine the left, right, and lower boundaries of the clipping window outline based on the positioning points of two adjacent inner ring outlines.
[0131] Step 1250: Following the order of the horizontal axis coordinates from smallest to largest, traverse the center points of all inner ring contours in turn, and dynamically construct the clipping window contour based on the center points of each pair of adjacent inner ring contours.
[0132] Step 1260: Spatially intersect the outline of each cropping window with the outline of the hole-shaped image to obtain multiple intersecting cropping results, and then spatially merge all the intersecting cropping results to obtain the outline merging result;
[0133] Step 1270: Spatial cropping is performed on the hole-shaped image outline and the outline merging result to obtain the outline cropping result;
[0134] Step 1280: Summarize the contour cropping results and all intersecting cropping results to obtain multiple non-hole-shaped image contours.
[0135] In this specific example, spatial indexing is first used to determine multiple target image contours near the spatial range of the image contour to be processed. Then, the image contour to be processed is spatially iterated and cropped with each target image contour in turn to obtain a hole-shaped image contour that can be represented by inner and outer rings. Next, based on the highest point of the vertical axis in the outer ring contour of the hole-shaped image contour and the center points of the two adjacent inner ring contours, all inner ring contours are traversed in turn to dynamically construct a cropping window contour for cutting. Then, multiple intersection cropping results are obtained by spatially intersecting the cropping window contour with the hole-shaped image contour in turn. After spatially merging all intersection cropping results, spatial cropping is performed with the hole-shaped image contour to obtain the remaining contour cropping results. At this point, after summarizing the contour cropping results and all intersection cropping results, multiple non-hole-shaped image contours after removing the target image contours from the image contour to be processed can be obtained. In this specific example, by using the method of cutting the hole-shaped image outline using the clipping window outline, the use of inner and outer ring representations to represent the hole-shaped image outline can be avoided. Therefore, the system that originally used single or multiple outline representations can achieve support for hole-shaped image outlines with minimal modifications, avoiding the problem of needing to redevelop existing task processes and tools to adapt to hole-shaped image outlines.
[0136] like Figure 13 As shown, Figure 13 This is a flowchart illustrating the steps involved in obtaining the outline of a hole in an image, as shown in a specific example. Figure 13 In this process, steps 1310 to 1350 may be included.
[0137] Step 1310: Determine the set of target object image contours in the contours of the image to be processed by spatial indexing.
[0138] Step 1320: Traverse each target object image contour in the target object image contour set.
[0139] Step 1330: Perform spatial cropping operation on the outline of the image to be processed and the outlines of each target object image.
[0140] In this step, assuming the contour of the image to be processed is r, the set of target object image contours determined in the contour r of the image to be processed by spatial indexing is Ω. t The outline of the target object image is t i Therefore, after performing spatial cropping operations on the contours of the image to be processed and the contours of each target object image, the result can be r. diff = r.difference(t i ),t i ∈Ω t , where r diff To obtain the hole-shaped image contour after spatially cropping the contour of the image to be processed and the contour of the target object image, r.difference(t i This indicates that the outline of the image to be processed and the outline of the target image are subjected to spatial cropping operation.
[0141] Step 1340: Determine whether all target object image contours in the target object image contour set have been traversed. If not, set t... i Updated to t i+1 If yes, proceed to step 1320; if yes, proceed to step 1350.
[0142] In this step, if the currently traversed target image contour is not the last one in the target image contour set, then the next target image contour is obtained from the target image contour set, and the next target image contour is spatially cropped with the image contour to be processed. This process is repeated until all target image contours in the target image contour set have been traversed.
[0143] Step 1350: Determine the hole-shaped image profile, including the outer ring profile and the inner ring profile.
[0144] In this step, after completing the spatial cropping operation between the outline of the image to be processed and the outlines of all target object images, the final r can be obtained. diff The image is identified as a hole-shaped profile, wherein the hole-shaped image profile includes an outer ring profile r. out and inner ring contour Ω in Outer ring contour r out The outer contour and inner ring contour Ω represent the outline of the hole-like image. in This represents the outline of the hole inside the hole-like image outline.
[0145] In this specific example, we can first determine the set of target image contours near the spatial range of the image contour to be processed using spatial indexing methods such as QT trees. Then, we traverse each target image contour in the target image contour set and perform spatial clipping operations on the image contour to be processed and each target image contour to obtain the spatial clipping result. Next, we use the spatial clipping result as the object for the next spatial clipping with the target image contour. We repeat the above steps to achieve iterative spatial clipping of the image contour to be processed and all target image contours until all target image contours have been traversed. Finally, we obtain a hole-shaped image contour that can be represented by inner and outer rings. The outer ring contour of the hole-shaped image contour represents the outer contour of the hole-shaped image contour, and each inner ring contour inside the hole-shaped image contour represents the contour of each hole inside the hole-shaped image contour.
[0146] like Figure 14 As shown, Figure 14 This is a flowchart illustrating the steps involved in constructing a clipping window outline, provided as a specific example. Figure 14 In this process, the procedure may include steps 1401 to 1410.
[0147] Step 1401: Obtain the maximum value of the vertical axis coordinate among all coordinate points of the outer ring contour.
[0148] Step 1402: Obtain the center points of each inner ring contour and generate a set of center points.
[0149] Step 1403: Sort all center points in the center point set in ascending order of their horizontal axis coordinate values to obtain the candidate window coordinate point set.
[0150] Step 1404: Initialize the record set used to store the outline of the clipping window.
[0151] Step 1405: If the number of elements in the candidate window coordinate point set is 1, add the vertex of the upper left corner of the outer ring contour as a candidate window coordinate point to the candidate window coordinate point set.
[0152] Step 1406: Traverse all candidate window coordinates in the candidate window coordinate point set.
[0153] Step 1407: Determine if there is a next candidate window coordinate point for the current candidate window coordinate point. If yes, proceed to step 1408; otherwise, proceed to step 1410.
[0154] In this step, assume that the i-th candidate window coordinate point in the candidate window coordinate point set is P. i (x i ,y i If we can determine the coordinates of the (i+1)th candidate window point P, then we can determine the coordinates of P. i+1(x i+1 ,y i+1 If the condition exists, proceed to step 1408; otherwise, proceed to step 1410.
[0155] Step 1408: Determine the left, right, and bottom boundaries of the current cropping window based on the coordinates of each pair of adjacent candidate windows.
[0156] In this step, since there exists a candidate window coordinate point P... i+1 (x i+1 ,y i+1 Therefore, the left boundary of the current cropping window can be determined as X. min =x i The right boundary is X max =x i+1 The lower boundary is Y min =min(y i ,y i+1 ).
[0157] Step 1409: Based on the maximum value of the vertical axis coordinates of the outer ring contour points and the left, right and lower boundaries of the current clipping window, construct the current clipping window contour and save the current clipping window contour to the record set. Then execute step 1406 to traverse the next candidate window coordinate point in the candidate window coordinate point set.
[0158] In this step, it is assumed that the maximum value of the ordinate of the outer ring contour coordinate points is Y. max Then, according to (X) min ,X max ,Y min ,Y max The current clipping window outline is constructed as m. i Then, the current cropping window outline m i Save to record collection Ω matrix In the middle, when the current cropping window outline m i Save to record collection Ω matrix After that, jump to step 1406 and iterate through the next candidate window coordinate point in the candidate window coordinate point set.
[0159] Step 1410: Output the outlines of multiple clipping windows in the record set.
[0160] In this specific example, we can first determine the maximum value of the vertical axis coordinate among all coordinate points of the outer ring contour, then traverse each inner ring contour, and calculate the center point coordinates of each inner ring contour by averaging the vertical axis coordinates and the horizontal axis coordinates of all coordinate points, forming a set of center points for all inner ring contours. Next, we sort the coordinate points in the center point set according to their horizontal axis coordinates from smallest to largest, obtaining a sorted set of center points. Then, we initialize the record set used to store the clipping window contour, traverse each center point in the sorted set according to their horizontal axis coordinates from smallest to largest, and determine if a next center point adjacent to the current center point exists. If it does, we set the horizontal axis coordinate of the current center point to the left boundary (X) of the current clipping window. min Set the x-axis coordinate of the next center point to the right boundary (X) of the current cropping window. max Set the minimum value of the y-axis coordinates of these two adjacent center points as the lower boundary Y of the current cropping window. min And set the maximum value of the ordinate of all coordinate points on the outer ring contour to the upper boundary Y of the current clipping window. max At this point, according to the left boundary X min Right boundary X max Lower boundary Y min and the upper boundary Y max The current clipping window outline for cutting can be constructed, wherein the clipping window outline may include (X... min ,Y min ), (X min ,Y max ), (X max ,Y max ) and (X maz ,Y min These four positioning points are used. By traversing adjacent pairs of center points each time, the cropping window contour can be dynamically constructed until all center points in the center point set have been traversed, at which point the constructed cropping window contour set can be output. It should be noted that if the initial center point set contains only one element, that is, if the image contour to be processed contains only one target image contour, then the vertex of the upper left corner of the outer ring contour can be added to the center point set so that the cropping window contour can be constructed in one step.
[0161] like Figure 15 As shown, Figure 15 This is a flowchart illustrating the steps involved in obtaining a non-hole-shaped image contour, provided as a specific example. Figure 15 In this process, steps 1510 to 1570 may be included.
[0162] Step 1510: Initialize the clipping result set used to store the intersection clipping results.
[0163] Step 1520: Iterate through the outlines of each clipping window in the record set.
[0164] Step 1530: Use the cropping window outline to spatially intersect the hole-shaped image outline to obtain the intersection cropping result, and save the intersection cropping result to the cropping result set.
[0165] In this step, we assume the set of cropping results is Ω. aplit The record set is Ω matrix The cropping window outline is m i The outline of the hole-like image is r diff Then step 1530 can be represented as Ω split .add(m i .intersection(r diff )),m i ∈Ω matrix , where m i .intersection(r diff ) indicates using the clipping window outline m i For the hole-shaped image contour r diff The intersection clipping result obtained by performing spatial intersection, Ω split .add(m i .intersection(r diff )) indicates that the intersection clipping result m i .intersection(r diff Save to the cropping result set Ω split middle.
[0166] Step 1540: Determine whether the outlines of each clipping window in the record set have been traversed. If not, proceed to step 1520; if yes, proceed to step 1550.
[0167] In this step, if the currently traversed cropping window outline is not the last one in the record set, then the next cropping window outline is obtained from the record set, and the next cropping window outline is spatially intersected with the hole image outline. This process is repeated until all cropping window outlines in the record set have been traversed.
[0168] Step 1550: Spatial merge of all intersecting clipping results in the clipping result set to obtain the outline merge result.
[0169] Step 1560: Spatial clipping is performed on the hole-shaped image contour and the contour merging result to obtain the remaining contour clipping result of the hole-shaped image contour.
[0170] In this step, we assume the contour merging result is r. union Then the remaining outline clipping result can be r other =
[0171] r diff .difference(r union ), where r diff .difference(r union ) indicates that the hole-shaped image outline r diff Result of contour merging r union Perform spatial clipping.
[0172] Step 1570: Summarize all the intersection cropping results and the remaining contour cropping results to obtain multiple non-hole image contours.
[0173] In this step, based on all intersecting clipping results and contour clipping results, we can obtain multiple non-hole-shaped image contours (Ω) after removing the target object image contour from the image to be processed. son =Ω split +{r other}
[0174] In this specific example, we can first initialize a cropping result set to store the intersecting cropping results after cutting the hole-shaped image contour using the cropping window contours. Then, we sequentially traverse each cropping window contour in the record set and perform a spatial intersection operation between each cropping window contour and the hole-shaped image contour to obtain the intersecting cropping results. Next, we record the intersecting cropping results in the cropping result set until all cropping window contours in the record set have been traversed. At this point, we perform a spatial merging operation on all the intersecting cropping results in the cropping result set to obtain the contour merging results. Then, we further perform a spatial cropping operation on the hole-shaped image contour and the contour merging results to obtain the remaining contour cropping results after cutting the hole-shaped image contour using all the cropping window contours. Finally, we summarize all the intersecting cropping results in the cropping result set and the remaining contour cropping results to obtain the set of all non-hole-shaped image contours after removing the target object image contour from the image contour to be processed. In other words, the image contour to be processed is transformed into a multi-contour image that does not contain the target object image contour.
[0175] The following examples illustrate the application scenarios of the embodiments of the present invention.
[0176] It should be noted that the image processing method provided in this embodiment of the invention can be applied to different application scenarios, such as processing the outline of the image to be processed during the research and development process and processing the outline of the image to be processed during the product operation process. The following description takes the scenarios of processing the outline of the image to be processed during the research and development process and processing the outline of the image to be processed during the product operation process as examples.
[0177] Scene 1
[0178] The image processing method provided in this invention can be applied to scenarios where the outline of an image to be processed needs to be processed during the research and development process. For example, suppose that the R&D personnel input the outline of the map image to be processed and the outline of the map target object through the image processing client in the user terminal (e.g., a computer). The user terminal will send the map image outline and the outline of the map target object to the data processing server for the cutting processing of the map image outline. When the data processing server receives the map image outline and the outline of the map target object sent by the user terminal, it first performs outline clipping on the map image outline according to the outline of the map target object to obtain a hole-shaped image outline including an outer ring outline and an inner ring outline. Then, it constructs a clipping window outline according to the outer ring outline and the inner ring outline of the hole-shaped image outline. Next, it performs outline clipping on the hole-shaped image outline according to the clipping window outline to obtain multiple non-hole-shaped image outlines. The union of all these non-hole-shaped image outlines can be used to represent the hole-shaped image outline. After the data processing server obtains these non-hole-shaped image outlines, it sends them to the user terminal for display. At this time, the R&D personnel can perform subsequent map data processing on these non-hole-shaped image outlines.
[0179] Scene 2
[0180] The image processing method provided in this invention can also be applied to scenarios where the outline of an image to be processed is processed during product operation. For example, assuming that after a map application system goes online, the processing server used to process map data obtains the outline of the map image to be processed from the application server used to run the map application system and storing the map data required during the operation of the map application system, and determines the outline of the map target object in the map image outline. After obtaining the map image outline and the outline of the map target object, the processing server first performs outline clipping on the map image outline according to the outline of the map target object to obtain a hole-shaped image outline including an outer ring outline and an inner ring outline. Then, it constructs a clipping window outline based on the outer ring outline and the inner ring outline of the hole-shaped image outline. Next, it performs outline clipping on the hole-shaped image outline according to the clipping window outline to obtain multiple non-hole-shaped image outlines. The union of all these non-hole-shaped image outlines can be used to represent the hole-shaped image outline. After the processing server obtains these non-hole-shaped image outlines, it sends them to the application server for subsequent map data processing.
[0181] It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0182] Reference Figure 16 The present invention also discloses an image processing apparatus 1600, which is capable of implementing the image processing method in the preceding embodiments. The image processing apparatus 1600 includes:
[0183] The contour acquisition unit 1610 is used to acquire the contour of the image to be processed and the contour of the target image, wherein the contour of the image to be processed includes the contour of the target image or intersects with the contour of the target image.
[0184] The first cropping unit 1620 is used to crop the outline of the image to be processed according to the outline of the target object image to obtain the hole-shaped image outline, wherein the hole-shaped image outline includes an outer ring outline and an inner ring outline.
[0185] The contour construction unit 1630 is used to construct the clipping window contour based on the outer ring contour and the inner ring contour.
[0186] The second cropping unit 1640 is used to crop the hole-shaped image contour according to the cropping window contour to obtain multiple non-hole-shaped image contours, wherein the union of all non-hole-shaped image contours is used to represent the hole-shaped image contour.
[0187] In one embodiment, the contour construction unit 1630 is further configured to:
[0188] Determine the coordinates of the first window based on the outer ring profile;
[0189] Determine the coordinate points of the second window based on the inner ring outline;
[0190] The outline of the clipping window is constructed based on the coordinates of the first window and the second window.
[0191] In one embodiment, the contour construction unit 1630 is further configured to:
[0192] Obtain the coordinates of all outer ring contour points;
[0193] The point with the largest vertical axis coordinate value among all outer ring contour coordinate points is determined as the first window coordinate point.
[0194] In one embodiment, the contour construction unit 1630 is further configured to:
[0195] Obtain the coordinates of all inner ring contour points within the inner ring contour;
[0196] Determine the center point of the inner ring profile based on the coordinate points of all inner ring profile points;
[0197] The center point is determined as the coordinate point of the second window.
[0198] In one embodiment, the contour construction unit 1630 is further configured to:
[0199] Calculate the average of the horizontal axis coordinates of all inner ring contour points to obtain the horizontal axis coordinate of the center point;
[0200] Calculate the average of the ordinate values of all inner ring contour points to obtain the ordinate value of the center point;
[0201] The center point of the inner ring profile is determined based on the horizontal and vertical coordinates of the center point.
[0202] In one embodiment, the number of inner ring contours is multiple, and the number of second window coordinate points determined based on the multiple inner ring contours is also multiple; the contour construction unit 1630 is further used for:
[0203] Sort the multiple second window coordinate points in ascending order of their horizontal axis coordinate values to obtain multiple candidate window coordinate points;
[0204] Multiple clipping window outlines are constructed based on the coordinates of the first window and the coordinates of each pair of adjacent candidate windows.
[0205] In one embodiment, the contour building unit is further used for:
[0206] The upper boundary of each cropping window is determined based on the coordinates of the first window.
[0207] For each pair of adjacent candidate window coordinates, the left boundary of the current cropping window is determined by the smaller horizontal axis coordinate value, the right boundary of the current cropping window is determined by the larger horizontal axis coordinate value, and the bottom boundary of the current cropping window is determined by the smaller vertical axis coordinate value.
[0208] Multiple clipping window outlines are constructed based on the top, left, right, and bottom boundaries.
[0209] In one embodiment, the number of clipping window outlines is multiple, and the second clipping unit 1640 is further used for:
[0210] The hole-shaped image outline is intersected and cropped with the outline of each cropping window to obtain multiple intersecting cropping results;
[0211] The outline of the hole-shaped image is cropped by all intersecting cropping results to obtain the outline cropping result.
[0212] The contour cropping results and all intersecting cropping results are combined to obtain multiple non-hole-shaped image contours.
[0213] In one embodiment, the second cutting unit 1640 is further configured to:
[0214] Merge the outlines of all intersecting clipping results to obtain the outline merged result;
[0215] The contour of the hole-shaped image is combined with the contour merging result and then the contour is cropped to obtain the contour cropping result.
[0216] In one embodiment, the number of target object image outlines is multiple, and the first cropping unit 1620 is further configured to:
[0217] The outline of the image to be processed is cropped by comparing it with the outline of the current target object image to obtain the cropped image outline.
[0218] The outline of the cropped image is cropped along with the outline of the next target image until all target image outlines are cropped, resulting in a hole-shaped image outline.
[0219] In one embodiment, the contour acquisition unit 1610 is further configured to:
[0220] Obtain the outline of the image to be processed;
[0221] Spatial indexing is performed on the contour of the image to be processed to obtain the contour of the target object image.
[0222] It should be noted that since the image processing device 1600 of this embodiment can implement the image processing method of the previous embodiment, the image processing device 1600 of this embodiment and the image processing method of the previous embodiment have the same technical principle and the same beneficial effect. In order to avoid repetition, it will not be described again here.
[0223] Reference Figure 17 The present invention also discloses an image processing apparatus, the image processing apparatus 1700 comprising:
[0224] At least one processor 1701;
[0225] At least one memory 1702 is used to store at least one program;
[0226] When at least one program is executed by at least one processor 1701, the image processing method as described in the preceding embodiments is implemented.
[0227] This invention also discloses a computer-readable storage medium storing a processor-executable computer program, which, when executed by a processor, implements the image processing method as described in the preceding embodiments.
[0228] This invention also discloses a computer program product, including a computer program or computer instructions, which are stored in a computer-readable storage medium. The processor of the image processing device reads the computer program or computer instructions from the computer-readable storage medium and executes the computer program or computer instructions, causing the image processing device to perform the image processing method as described in the preceding embodiments.
[0229] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.
[0230] It should be understood that in this invention, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0231] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, apparatuses, or units, and may be electrical, mechanical, or other forms.
[0232] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0233] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0234] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0235] The step numbers in the above method embodiments are set only for ease of explanation and do not limit the order of the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
Claims
1. An image processing method, characterized in that, Includes the following steps: Obtain the outline of the image to be processed and the outline of the target image, wherein the outline of the image to be processed includes the outline of the target image or intersects with the outline of the target image; Based on the target object image contour, the image contour to be processed is cropped to obtain a hole-shaped image contour, wherein the hole-shaped image contour includes an outer ring contour and an inner ring contour; Obtain the coordinates of all outer ring contour points in the outer ring contour; The coordinate point with the largest vertical axis coordinate value among all the outer ring contour coordinate points is determined as the first window coordinate point; Obtain all inner ring contour coordinate points in the inner ring contour, determine the center point of the inner ring contour based on all the inner ring contour coordinate points, and determine the center point as the second window coordinate point. There are multiple inner ring contours, and there are multiple second window coordinate points determined based on multiple inner ring contours. Sort the multiple second window coordinate points in ascending order of their horizontal axis coordinate values to obtain multiple candidate window coordinate points after sorting. The upper boundary of each cropping window is determined based on the vertical axis coordinate value of the first window coordinate point. For each pair of adjacent candidate window coordinate points, the left boundary of the current cropping window is determined based on the smaller horizontal axis coordinate value, the right boundary of the current cropping window is determined based on the larger horizontal axis coordinate value, and the lower boundary of the current cropping window is determined based on the smaller vertical axis coordinate value. Multiple cropping window outlines are constructed based on the upper boundary, the left boundary, the right boundary, and the lower boundary. The hole-shaped image outline is intersected and cropped with the outline of each cropping window to obtain multiple intersecting cropping results; Perform contour merging on all the intersecting clipping results to obtain the contour merging result; The contour of the hole-shaped image is combined with the contour merging result and then the contour is cropped to obtain the contour cropping result. The contour cropping results and all the intersection cropping results are summarized to obtain multiple non-hole image contours, wherein the union of all the non-hole image contours is used to characterize the hole image contour.
2. The image processing method according to claim 1, characterized in that, Determining the center point of the inner ring contour based on all the coordinate points of the inner ring contour includes: Calculate the average of the horizontal axis coordinates of all the inner ring contour coordinate points to obtain the horizontal axis coordinate of the center point; Calculate the average of the ordinate values of all the coordinate points of the inner ring contour to obtain the ordinate value of the center point; The center point of the inner ring profile is determined based on the horizontal axis coordinate value and the vertical axis coordinate value of the center point.
3. The image processing method according to claim 1, characterized in that, The number of target object image contours is multiple. The step of cropping the image contours to be processed based on the target object image contours to obtain hole-shaped image contours includes: The outline of the image to be processed is cropped by the outline of the current target image to obtain the cropped image outline. The cropped image outline is cropped along with the next target image outline until all target image outlines are cropped, resulting in a hole-shaped image outline.
4. The image processing method according to claim 1, characterized in that, The process of obtaining the contours of the image to be processed and the object image includes: Obtain the outline of the image to be processed; Spatial indexing is performed on the image contour to be processed to obtain the image contour of the target object.
5. An image processing apparatus, characterized in that, include: A contour acquisition unit is used to acquire the contour of the image to be processed and the contour of the target image, wherein the contour of the image to be processed includes the contour of the target image or intersects with the contour of the target image; The first cropping unit is used to crop the outline of the image to be processed according to the outline of the target object image to obtain a hole-shaped image outline, wherein the hole-shaped image outline includes an outer ring outline and an inner ring outline. A contour construction unit is used to obtain all outer ring contour coordinate points in the outer ring contour; determine the coordinate point with the largest vertical axis coordinate value among all the outer ring contour coordinate points as the first window coordinate point; obtain all inner ring contour coordinate points in the inner ring contour, determine the center point of the inner ring contour based on all the inner ring contour coordinate points, and determine the center point as the second window coordinate point. There are multiple inner ring contours, and multiple second window coordinate points determined based on the multiple inner ring contours. The multiple second window coordinate points are sorted in ascending order of horizontal axis coordinate values to obtain multiple sorted candidate window coordinate points. The upper boundary of each clipping window is determined based on the vertical axis coordinate value of the first window coordinate point. For each pair of adjacent candidate window coordinate points, the left boundary of the current clipping window is determined based on the smaller horizontal axis coordinate value, the right boundary is determined based on the larger horizontal axis coordinate value, and the lower boundary is determined based on the smaller vertical axis coordinate value. Multiple clipping window contours are constructed based on the upper boundary, the left boundary, the right boundary, and the lower boundary. The second cropping unit is used to perform intersection cropping of the hole-shaped image contour with each of the cropping window contours to obtain multiple intersection cropping results; to merge the contours of all the intersection cropping results to obtain a contour merging result; to crop the contours of the hole-shaped image contour with the contour merging result to obtain a contour cropping result; and to summarize the contour cropping result and all the intersection cropping results to obtain multiple non-hole-shaped image contours, wherein the union of all the non-hole-shaped image contours is used to represent the hole-shaped image contour.
6. An image processing apparatus, characterized in that, include: At least one processor; At least one memory for storing at least one program; The image processing method as described in any one of claims 1 to 4 is implemented when at least one of the programs is executed by at least one of the processors.
7. A computer-readable storage medium, characterized in that, It contains a processor-executable computer program, which, when executed by the processor, is used to implement the image processing method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Interactive image segmentation method
CN103049907A
Picture clipping method and device in online presentation file, storage medium and equipment
CN110568982A