Image search method, device, product, equipment and medium
By adopting multiple search directions in the image and skipping the searched contours with correlation indication data, the problem of inefficient contour search in the prior art is solved, and efficient search of large images or multi-contour images is achieved.
Patent Information
- Application Number
- CN202311295252.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2043-09-28
AI Technical Summary
The prior art is less efficient when conducting contour searches in large or multi-contour images, especially when the images are larger or the number of contours is large, resulting in a significant reduction in search efficiency.
Multiple search directions are adopted and the contour in the searched direction is skipped by the associated indication data, and the contour search of the target image is realized, and the converted data in each search direction is obtained to skip repeated searches, improving search efficiency.
Through multi-directional search and indication data association, repeated searches for the same contour are avoided, and the search efficiency of contours in the image is significantly improved, ensuring the integrity and consistency of the search.
Smart Images

Figure CN117409027B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image processing, and in particular to an image search method, apparatus, product, equipment and medium. Background Art
[0002] In many scenarios, it is usually necessary to search for contours contained in an image, so that the corresponding object (ie, target) to which the contour belongs in the image can be quickly located through the searched contours.
[0003] In existing applications, contour search is usually performed on an image in a specified direction. When the image is large or contains many contours, the efficiency of the contour search on the image will be very low. Summary of the invention
[0004] The present application provides an image search method, apparatus, product, device and medium, which can improve the search efficiency for contours in a target image.
[0005] On one hand, the present application provides an image search method, the method comprising:
[0006] Perform contour search on the target image along N search directions; N is an integer greater than 1;
[0007] Acquire conversion data of contours searched along each of N search directions; any one of the N search directions is a first search direction, and the conversion data of contours searched along the first search direction includes indication data respectively associated with each of the search directions except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction;
[0008] In the process of performing contour search on the target image, in each of the N search directions, the contour search of the indicated contour corresponding to the respective search direction is skipped to obtain the contour searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction;
[0009] The contours in the target image include contours searched along N search directions.
[0010] On one hand, the present application provides an image search device, which includes:
[0011] A search module, used for performing contour search on a target image along N search directions; N is an integer greater than 1;
[0012] An acquisition module, used to acquire conversion data of contours searched along each of N search directions; any search direction among the N search directions is a first search direction, and the conversion data of the contours searched along the first search direction includes indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction;
[0013] The search module is further used to skip the contour search of the indicated contour corresponding to each of the N search directions in the process of performing contour search on the target image, and obtain the contour searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction;
[0014] The contours in the target image include contours searched along N search directions.
[0015] Optionally, the search module performs contour search on the target image along N search directions, including:
[0016] Performing binarization processing on the target image to obtain a binary image of the target image;
[0017] Perform contour search on the binary image along N search directions.
[0018] Optionally, the process of the search module performing contour search on the binary image along the first search direction includes:
[0019] Searching pixel points in the binary image in sequence along a first search direction;
[0020] When the first pixel point is searched, a contour search is performed based on the first pixel point to search for a target contour where the first pixel point is located;
[0021] The first pixel point refers to a pixel point that meets the contour start search condition in the first search direction.
[0022] Optionally, a contour searched along the first search direction has a conversion data, the target contour is any contour searched along the first search direction, and any indication data associated with a search direction other than the first search direction is the indication data of the target contour in the search direction;
[0023] The process of obtaining the conversion data of the target contour searched along the first search direction by the acquisition module includes:
[0024] In the binary image, obtaining the contour starting point of the target contour in each search direction except the first search direction;
[0025] Based on the contour starting point of the target contour in each search direction except the first search direction, generating indication data of the target contour in each search direction;
[0026] Determine the indication data of the target contour in each search direction except the first search direction as the conversion data of the target contour;
[0027] Among them, the target contour has a contour starting point in each of the N search directions, and the contour starting point of the target contour in a search direction refers to the first pixel point on the target contour searched in the contour search in the search direction that meets the contour starting search conditions in the search direction.
[0028] Optionally, the acquisition module generates indication data in each search direction based on the contour starting point of the target contour in each search direction except the first search direction, including:
[0029] Obtaining pixel coordinates of the starting points of the target contour in each search direction except the first search direction in the binary image;
[0030] The pixel coordinates of the starting point of the target contour in each search direction except the first search direction are determined as the indication data of the target contour in the respective search directions.
[0031] Optionally, any search direction among the N search directions except the first search direction is a second search direction;
[0032] In the process of performing contour search on the target image by the search module, the contour search of the indicated contour corresponding to each of the N search directions is skipped in each of the N search directions, and the contour searched along each of the N search directions is obtained, including:
[0033] When a second pixel point that meets the contour start search condition in the second search direction is searched along the second search direction, and it is detected that the second pixel point belongs to the pixel point indicated by the indication data of the target contour in the second search direction, the contour search process based on the second pixel point is skipped in the second search direction; and
[0034] Based on the indication data of the target contour in the second search direction, each pixel point on the target contour is obtained, and in the second search direction, the contour search process based on each pixel point on the target contour except the second pixel point is skipped.
[0035] Optionally, when or after searching for the target contour along the first search direction, the device is further used to:
[0036] Obtain the pixel coordinates of each pixel point on the searched target contour in the binary image;
[0037] Using the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour are recorded in association;
[0038] Based on the indication data of the target contour in the second search direction, each pixel point on the target contour is obtained, including:
[0039] Based on the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour of the associated record are obtained.
[0040] Optionally, the pixel value of the pixel point in the binary image is a first pixel value or a second pixel value, and the first pixel value is greater than the second pixel value;
[0041] The target contour is a hole boundary type or an outer boundary type. If the target contour is a hole boundary type, the pixel values of the pixels within the target contour are all the second pixel values;
[0042] If the target contour is an outer boundary type, the pixel values of the pixel points within the target contour are all first pixel values, and the pixel values of the pixel points outside the target contour and adjacent to the target contour are second pixel values.
[0043] Optionally, the first search direction is a reverse search direction or a forward search direction; the reverse search direction refers to a direction of searching for pixel points that meet the contour start search condition in the first search direction in the binary image from left to right and from top to bottom, and the forward search direction refers to a direction of searching for pixel points that meet the contour start search condition in the first search direction in the binary image from right to left and from bottom to top;
[0044] Wherein, the first pixel is represented as (i, j), the pixel value of the first pixel is represented as f(i, j), i is the longitudinal coordinate of the first pixel in the binary image, j is the transverse coordinate of the first pixel in the binary image, and both i and j are non-negative integers;
[0045] If the target contour is a hole boundary type, and the first search direction is a reverse search direction, the initial search condition for the contour in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value;
[0046] If the target contour is a hole boundary type, and the first search direction is a forward search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value;
[0047] If the target contour is an outer boundary type, and the first search direction is a reverse search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value;
[0048] If the target contour is an outer boundary type and the first search direction is a forward search direction, the contour starting search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value.
[0049] Optionally, the search module performs contour search based on the first pixel point to search for a target contour where the first pixel point is located, including:
[0050] In the binary image, starting from the first pixel point, searching for a plurality of pixel points that are connected in series and whose pixel values are all the first pixel value;
[0051] Based on the first pixel point and the searched multiple pixel points, a searched target contour is determined.
[0052] Optionally, the above device is also used for:
[0053] In the target image, the contour searched for the target image is identified;
[0054] In the target image, an image within the identified contour is segmented; the image belongs to a local image in the target image.
[0055] In one aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes a method in one aspect of the present application.
[0056] In one aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes the method in the above aspect.
[0057] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in various optional modes such as the above-mentioned one aspect.
[0058] The present application can perform contour search on a target image along N search directions; N is an integer greater than 1; and conversion data of contours searched along each of the N search directions can be obtained; any search direction among the N search directions is a first search direction, and the conversion data of contours searched along the first search direction include indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction; and, in the process of performing contour search on the target image, contour search for indicated contours corresponding to each of the N search directions can be skipped in each of the N search directions to obtain contours searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction; wherein, the contour in the target image includes the contours searched along the N search directions. It can be seen that the method proposed in the present application can perform contour search on the target image along multiple search directions (i.e., N search directions) at the same time, and in the process of performing contour search along multiple search directions, in each search direction, the contour search of the contour that has been searched in other search directions can be skipped through the associated indication information, so that the same contour in the target image will not be searched repeatedly in each search direction, thereby greatly improving the efficiency of searching for contours in the target image. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions in the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 It is a structural diagram of a network architecture provided by an embodiment of the present application;
[0061] Figure 2 is a schematic diagram of a scene of contour search provided in an embodiment of the present application;
[0062] Figure 3 is a flowchart of an image search method provided in an embodiment of the present application;
[0063] Figure 4a-4c is a schematic diagram of a structure of a pixel neighborhood provided in an embodiment of the present application;
[0064] Figure 5a-Figure 5b is a schematic diagram of a reverse contour search scenario provided by an embodiment of the present application;
[0065] Figure 6a-6bis a schematic diagram of a scenario for determining a starting point of a contour provided in an embodiment of the present application;
[0066] Figure 7 is a schematic diagram of an image segmentation scene provided by an embodiment of the present application;
[0067] Figure 8 is a structural schematic diagram of an image search device provided in an embodiment of the present application;
[0068] Fig. 9 is a structural schematic diagram of another image search device provided in an embodiment of the present application;
[0069] Fig.10 It is a structural schematic diagram of a computer device provided by this application. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0071] This application involves artificial intelligence related technologies. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0072] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, pre-trained models are also called large models and basic models. After fine-tuning, they can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0073] This application mainly involves computer vision technology (CV) in artificial intelligence. Among them, computer vision is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the visual field such as swin-transformer (a self-attention neural network), ViT (visiontransformer, a visual model), V-MOE (a sparse mixed model), and MAE (an autoencoder model) can be quickly and widely applied to downstream specific tasks after fine tuning.
[0074] Among them, computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, OCR (optical character recognition), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D (3D) technology, virtual reality, augmented reality, simultaneous positioning and map construction, and also includes common biometric recognition technologies such as face recognition and fingerprint recognition.
[0075] In the present application, the contours in the image can be quickly and accurately searched mainly by using computer vision technology, and details can be found in the relevant descriptions in the following embodiments.
[0076] First of all, it should be noted that all data collected in this application (such as target images for contour search and other relevant data) are collected with the consent and authorization of the object to which the data belongs (such as users, institutions or enterprises), and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0077] See also Figure 1 , Figure 1 Schematic diagram of a network architecture provided by an embodiment of the present application. Figure 1 As shown, the network architecture may include a server 200 and a terminal device cluster, and the terminal device cluster may include one or more terminal devices, and the number of terminal devices is not limited here. Figure 1 As shown, the multiple terminal devices may specifically include terminal device 1, terminal device 2, terminal device 3, ..., terminal device n; Figure 1As shown, terminal device 1, terminal device 2, terminal device 3, ..., terminal device n can all be connected to the server 200 through a network, so that each terminal device can exchange data with the server 200 through the network connection.
[0078] like Figure 1 The server 200 shown can be an independent physical server, or 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 communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal device can be a smart terminal such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart TV, etc. The following takes the communication between the terminal device 1 and the server 200 as an example to describe the specific embodiments of the present application.
[0079] Please also see Figure 2 , Figure 2 1 is a schematic diagram of a contour search scenario provided by an embodiment of the present application. A user can upload a target image to be contour searched in the terminal device 1, and then the terminal device 1 can send the target image to the server 200 to request the server 200 to perform a contour search on the target image. The process of the server 200 performing a contour search on the target image may include:
[0080] The server 200 can simultaneously perform contour searches on the target image along multiple search directions, such as the multiple search directions can include the direction from top to bottom and from left to right here (which can be called a reverse search direction), and the direction from bottom to top and from right to left (which can be called a forward search direction).
[0081] Among them, in the process of performing contour search on the target image along the reverse search direction, conversion data of the contour searched along the reverse search direction (which can be recorded as conversion data 1) can be obtained, and the conversion data 1 can be used in the contour search in the forward search direction to indicate the contour searched along the reverse search direction; and similarly, in the process of performing contour search on the target image along the forward search direction, conversion data of the contour searched along the forward search direction (which can be recorded as conversion data 2) can be obtained, and the conversion data 2 can be used in the contour search in the reverse search direction to indicate the contour searched along the forward search direction.
[0082] Furthermore, in the contour search in the reverse search direction, the search process for the contour indicated by the conversion data 2 can be skipped (i.e., the search process for the contour that has been searched in the forward search direction can be skipped), and in the contour search in the forward search direction, the search process for the contour indicated by the conversion data 1 can be skipped (i.e., the search process for the contour that has been searched in the reverse search direction can be skipped).
[0083] Through the above process, contour 1 and contour 2 in the target image can be searched along the reverse search direction, and contour 3 and contour 4 in the target image can be searched along the forward search direction. All contours in the target image may include contour 1 and contour 2 searched along the reverse search direction, and may include contour 3 and contour 4 searched along the forward search direction.
[0084] It can be understood that based on the different complexities of the contours in the target image and the different positions of the contours, the time spent searching for the corresponding contours along each search direction may be different. Therefore, the number of contours searched along different search directions may also be different. The specific number of contours searched in each search direction can be determined based on the actual application scenario and is not limited to this.
[0085] After searching for the contours in the target image, the server 200 can identify the searched contours in the target image, and can return the target image with the identified contours to the terminal device 1. The terminal device 1 can perform further business processing on the target image with the identified contours according to actual application requirements. For example, the image within the contour identified in the target image can be segmented out to obtain a local image of the target image within the contour. The local image can belong to the foreground image segmented from the target image, and so on.
[0086] By adopting the method provided in the present application, contour searches can be performed on images simultaneously (in parallel) along multiple search directions. Moreover, in the process of simultaneously searching the contours of the image along each search direction, conversion data of the contours searched along each search direction can also be obtained. Subsequently, based on the conversion data, the search process for contours that have been searched in other search directions can be skipped in each search direction. Therefore, the search efficiency for contours in the image can be greatly improved, so that each contour in the image can be quickly searched and obtained.
[0087] See also Figure 3 , Figure 3 : is a flowchart of an image search method provided in an embodiment of the present application. The execution subject in the embodiment of the present application may be an image search device, which may be a computer device or a computer device cluster composed of multiple computer devices. The computer device may be a server, a terminal device, or other devices, without limitation. Figure 3 As shown, the method may include:
[0088] Step S101, performing contour search on a target image along N search directions; N is an integer greater than 1.
[0089] Optionally, the N search directions may be set according to actual application scenarios, where N is an integer greater than 1, i.e., the N search directions are multiple search directions, and N is at least equal to 2. The N search directions are directions for searching for contours of the target image, i.e., the N search directions are directions for searching for contours in the target image.
[0090] The image search device can obtain a target image, and the target image can be any image that needs to be searched for contours. The specific image of the target image can be determined according to the actual application scenario. For example, the target image can be an image that needs to be segmented for the foreground, and the foreground image in the target image (such as a partial image of an object in the target image) can be segmented by the contour searched for the target image; for another example, the target image can be an image that needs to detect a target object (such as an object), and the target object in the target image can be segmented by the contour searched for the target image; for another example, the target image can be an image that needs to detect a target area (such as the area of an organ in the medical field), and the image of the target area in the target image can be extracted by the contour searched for the target image.
[0091] From the above, it can be understood that the present application can be applied to any scenario where contour search (same as detection) is required for an image. The specific application scenario can be determined according to the actual application scenario and is not limited to this.
[0092] The image search device can simultaneously (i.e. synchronously, which can be understood as parallel) perform contour search on the target image along the above-mentioned N search directions to search for the contour in the target image. In order to more accurately perform contour search on the target image, the target image can be binarized to obtain a binarized image of the target image (which can be called a binary image), the dimension of which is the same as that of the target image, and the pixels in the target image and the binary image can correspond one to one (the pixel coordinates of the pixels in the target image and the pixels in the binary image can be the same), that is, a pixel in the target image after binarization is a pixel in the binary image.
[0093] As the name implies, the value range of the pixel value of a pixel point in a binary image includes two pixel values, which can be 0 and 1, 0 represents black, and 1 represents white, that is, the binary image can be a black and white image, and the pixel value of a pixel point in the binary image can be a pixel value 0 or a pixel value 1. The pixel value 1 can be called the first pixel value, and the pixel value 0 can be called the second pixel value, and the first pixel value is greater than the second pixel value. Therefore, the pixel value of each pixel point in the binary image can be the first pixel value or the second pixel value.
[0094] Therefore, the image search device performs contour search on the target image along N search directions, which may refer to performing contour search on the binary image of the target image along the N search directions, wherein the contour search in each search direction may be performed independently.
[0095] Optionally, the above-mentioned N search directions may include a forward search direction and a reverse search direction, the reverse search direction may refer to a search direction for performing contour search on a binary image from left to right and from top to bottom, and the forward search direction may refer to a search direction for performing contour search on a binary image from right to left and from bottom to top.
[0096] In some possible implementations, the above-mentioned N search directions may also include other search directions, such as a search direction from left to right and from bottom to top, or / and a search direction from right to left and from top to bottom, etc., which can be determined based on the actual application scenario. Which search directions the N search directions specifically include can be determined based on the actual application scenario. No matter how many or which N search directions there are, the principle of processing between the two search directions is the same. Therefore, the following process of the present application can be illustrated by taking the above-mentioned N search directions including a forward search direction and a reverse search direction as an example, which can be specifically described as follows.
[0097] Step S102, obtaining conversion data of the contour searched along each of N search directions; any search direction among the N search directions is a first search direction, and the conversion data of the contour searched along the first search direction includes indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contour searched along the first search direction in the contour search in the associated search direction.
[0098] Optionally, the image search device may obtain conversion data of contours searched along each of the N search directions, wherein each time a contour is searched along a search direction, the conversion data of the contour may be generated in real time. It is understandable that a contour searched in a search direction may have a conversion data, and the conversion data is used in contour searches in other search directions to indicate the contour searched in the search direction, and the details may be referred to the following description.
[0099] Any one of the N search directions can be referred to as the first search direction, that is, the first search direction can be any one of the N search directions. The following mainly takes the first search direction as an example to describe the relevant characteristics of contour search along the search direction. It can be understood that, since the first search direction can be any search direction, the contour search in each search direction can have the relevant characteristics described below for the contour search in the first search direction.
[0100] The conversion data of the contour searched along the first search direction may include indication data associated with each of the N search directions except the first search direction. The indication data can be used in the contour search in the associated search direction to indicate the contour searched along the first search direction.
[0101] The contours searched along the first search direction may include contours that have not been searched in other search directions when the contours are searched in the first search direction.
[0102] In the present application, the pixel points in the binary image that meet the contour starting search conditions of each search direction can be searched along each search direction, and then the contour to which the pixel point is located (i.e., belongs) can be searched with the pixel point as the starting point. Here, the contour search of the binary image along the first search direction is performed, and the process of searching and obtaining the corresponding contour is described as an example, and the process may include:
[0103] The image search device can search for pixels in the binary image in sequence along a first search direction, and when a first pixel is found, a contour search can be performed based on the first pixel to search for a contour where the first pixel is located. The contour where the first pixel is located can be referred to as a target contour, and the target contour can be any contour found along the first search direction.
[0104] Among them, the first pixel point may refer to a pixel point that meets the contour starting search conditions in the first search direction, and the first pixel point may be the first pixel point on the target contour searched along the first search direction that meets the contour starting search conditions in the first search direction. Therefore, the first pixel point may be called the contour starting point of the target contour in the first search direction.
[0105] First, it should be noted that the points on the contour are all pixel points whose pixel values are the first pixel value, that is, the contour may be composed of pixel points whose pixel values are all 1. The target contour may be a hole boundary type contour or an outer boundary type contour, the hole boundary type contour may refer to a contour whose internal pixel value is 0, and the outer boundary type contour may refer to a contour whose internal pixel value is 1 and whose external adjacent pixel value is 0.
[0106] Therefore, if the target contour is a hole boundary type contour (which may be referred to as a hole boundary contour), the pixel values of the pixels within the target contour may all be the second pixel value (i.e., pixel value 0). If the target contour is an outer boundary type contour (which may be referred to as an outer boundary contour), the pixel values of the pixels within the target contour may all be the first pixel value (i.e., pixel value 1), and the pixel values of the pixels outside the target contour that are adjacent to (immediately adjacent to) the target contour may be the second pixel value (i.e., pixel value 0).
[0107] Optionally, the first search direction may be the reverse search direction or the forward search direction. The reverse search direction may refer to searching each row of pixel points in the binary image from left to right and from top to bottom in turn to search for pixel points that meet the contour starting search conditions in the first search direction; and the forward search direction may refer to searching each row of pixel points in the binary image from right to left and from bottom to top in turn to search for pixel points that meet the contour starting search conditions in the first search direction.
[0108] Among them, the above-mentioned first pixel point can be represented as (i, j), and the pixel value of the first pixel point can be represented as f(i, j), i and i are both non-negative integers, i can be the longitudinal coordinate of the first pixel point in the binary image (such as the number of rows, which can be counted from 0 or 1), and j can be the horizontal coordinate of the first pixel point in the binary image (such as the number of columns, which can also be counted from 0 or 1).
[0109] Therefore, based on the above description of the hole boundary type contour and the outer boundary type contour, it can be understood that if the target contour is a hole boundary type, and the first search direction is a reverse search direction, then the contour starting search condition in the first search direction that the first pixel point meets can be: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value. In other words, if it is necessary to search for a hole boundary type contour in the target image along the reverse search direction, a pixel point whose pixel value is 1 and the pixel value of a pixel point adjacent to the right is 0 can be searched in the binary image, and the contour where the pixel point is located can be searched from the pixel point.
[0110] If the target contour is a hole boundary type, and the first search direction is a forward search direction, then the contour starting search condition in the first search direction that the first pixel point meets may be: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value. In other words, if it is necessary to search for a hole boundary type contour in the target image along the forward search direction, a pixel point whose pixel value is 1 and whose left adjacent pixel value is 0 may be searched in the binary image, and the contour where the pixel point is located may be searched from the pixel point.
[0111] Furthermore, if the target contour is of an outer boundary type, and the first search direction is a reverse search direction, the initial search condition of the contour in the first search direction that the first pixel point meets may be: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value. In other words, if it is necessary to search for an outer boundary type contour in the target image along the reverse search direction, a pixel point whose pixel value is 1 and whose pixel value is 0 adjacent to the left can be searched in the binary image, and the contour where the pixel point is located can be searched from the pixel point.
[0112] If the target contour is an outer boundary type, and the first search direction is a forward search direction, then the contour starting search condition in the first search direction that the first pixel point meets may be: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value. In other words, if it is necessary to search for an outer boundary type contour in the target image along the forward search direction, a pixel point whose pixel value is 1 and whose pixel value is 0 adjacent to the right can be searched in the binary image, and the contour where the pixel point is located can be searched starting from the pixel point.
[0113] Among them, f(i, j-1) can refer to the pixel value of the pixel point in the same row as the first pixel point and in the column to the left of the first pixel point, and f(i, j+1) can refer to the pixel value of the pixel point in the same row as the first pixel point and in the column to the right of the first pixel point.
[0114] Further, when the image search device searches for the first pixel point according to the contour start search condition in the first search direction, it can start contour search based on the first pixel point to search for the target contour where the first pixel point is located. The process may include:
[0115] The image search device can search for multiple pixel points that are connected to each other and whose pixel values are all the first pixel value (i.e., pixel value 1) in a binary image starting from the first pixel point. Then, based on the first pixel point and the multiple pixel points obtained by searching from the first pixel point, the searched target contour can be determined. The target contour is composed of the first pixel point and the multiple pixel points obtained by searching from the first pixel point. The specific process can also be described in the following content.
[0116] To facilitate understanding of the specific process of contour search, the following first explains the meaning of the relevant coordinates involved in contour search through Table 1:
[0117] Pixel coordinates (i, j) Contour starting point Pixel coordinates (i1, j1) Start search base point Pixel coordinates (i2, j2) The starting boundary point for the contour search Pixel coordinates (i3, j3) The center point of each neighborhood search Pixel coordinates (i4, j4) The result of each neighborhood search Pixel coordinates (i5, j5) Convert coordinates
[0118] Table 1
[0119] If the first search direction is a reverse search direction, the process of searching along the reverse search direction to obtain the above-mentioned target contour may include: after searching for the starting point of the target contour in the first search direction (i.e., the first pixel point), the present application may first perform an initialization search based on the first pixel point and then perform a cyclic search. Each search in the cyclic search may search for a pixel point on the target contour. Ultimately, the search results obtained through the first pixel point and each search in the cyclic search may constitute the entire target contour that has been searched, as described below.
[0120] Search phase 1 for the target contour in the reverse search direction: Initialization search phase for the target contour in the reverse search direction.
[0121] The initialization search phase may be a phase of searching for a starting search base point (i1, j1). Among them, the contour starting point (i.e., the first pixel point) on the target contour searched from the binary image along the first search direction can be represented as the above-mentioned contour starting point (i, j), and then, based on the contour starting point (i, j), the starting boundary point (i2, j2) for the target contour in the reverse search direction can be determined; specifically, if the outer boundary contour needs to be searched currently, the pixel point (i, j-1) in the binary image can be used as the starting boundary point (i2, j2), that is, the pixel point on the adjacent left side of the same row as the contour starting point (i, j) is used as the starting boundary point (i2, j2), and the pixel value of the pixel point (i, j-1) is 0; if the hole boundary contour needs to be searched currently, the pixel point (i, j+1) in the binary image can be used as the starting boundary point (i2, j2), that is, the pixel point on the adjacent right side of the same row as the contour starting point (i, j) is used as the starting boundary point (i2, j2), and the pixel value of the pixel point (i, j+1) is 0. Furthermore, the starting search base point (i1, j1) can be searched from the binary image through the contour starting point (i, j) and the starting boundary point (i2, j2). The starting search base point (i1, j1) can be used to find the reference point of the starting boundary point of the contour search when performing a subsequent reverse contour search (i.e., a contour search in the reverse search direction).
[0122] Among them, the specific process of determining the starting search base point (i1, j1) may include: starting from the starting boundary point (i2, j2) and searching for the starting search base point (i1, j1) in a neighborhood of the contour starting point (i, j) in a clockwise direction; specifically, it may be taking the contour starting point (i, j) as the center, starting from the starting boundary point (i2, j2) and rotating clockwise to find the first non-zero point in the neighborhood of the contour starting point (i, j), and using the first non-zero point as the starting search base point (i1, j1).
[0123] The neighborhood mentioned above is a basic structure in the topological space, specifically a special interval centered on a certain pixel. The neighborhood of a pixel can be used to reflect the adjacency properties between the pixel and the surrounding pixels; according to different adjacency properties, it is usually divided into 4-neighborhood, 8-neighborhood and D-neighborhood, etc.
[0124] See also Figure 4a-4c , Figure 4a-4c is a schematic diagram of a pixel neighborhood structure provided by an embodiment of the present application. Figure 4a As shown, the pixel point P can be taken as the center point, and the four pixel points on the top (such as labeled 1), bottom (such as labeled 3), left (such as labeled 2) and right (such as labeled 0) that are adjacent to the center point can be taken as the four-domain of the pixel point P.
[0125] For example Figure 4b As shown, the pixel point P can also be taken as the center point, and the eight pixel points that are adjacent to the center point, namely, the top (such as labeled 2), bottom (such as labeled 6), left (such as labeled 4), right (such as labeled 0), upper left (such as labeled 3), upper right (such as labeled 1), lower left (such as labeled 5) and lower right (such as labeled 7), can be taken as the 8-neighborhood of the pixel point P.
[0126] More, such as Figure 4c As shown, the pixel point P can be taken as the center point, and the pixel points on the four diagonals of the upper left (such as labeled 3), upper right (such as labeled 1), lower left (such as labeled 5) and lower right (such as labeled 7) that have an adjacent relationship with the pixel point P can be taken as the D neighborhood of the pixel point P.
[0127] It should be noted that the image search method provided in the embodiment of the present application has wide versatility and can be applied to contour searches in any neighborhood including but not limited to 4-neighborhood, 8-neighborhood and D-neighborhood; the embodiment of the present application does not limit the neighborhood of the specific application, and the neighborhood of the specific application can be determined according to the actual application scenario.
[0128] Search phase 2 for the target contour in the reverse search direction: a cyclic search phase for the target contour in the reverse search direction.
[0129] The cyclic search phase for the target contour can be implemented based on the starting search base point (i1, j1) of the above-mentioned initialization search phase. Specifically, a cyclic search can be performed based on the starting search base point (i1, j1) and the contour starting point (i, j) to search for corresponding search results (i.e., the results of the neighborhood search). The search results obtained belong to the pixel points on the target contour. The cyclic search can have one or more searches until the search results meet the contour search end condition, then the contour search can be stopped and the corresponding contour searched (such as the target contour) can be obtained. The following content is described.
[0130] Specifically, the starting search base point (i1, j1) obtained in the initialization phase can be used as the starting boundary point (i2, j2) of the first search in the cyclic search phase, and the contour starting point (i, j) can be used as the center point (i3, j3) of the neighborhood search in the first search in the cyclic search phase. Then, based on the starting boundary point (i2, j2) and the center point (i3, j3) of the first search in the cyclic search phase, the binary image can be searched for the first time in the cyclic search phase to obtain the search result (i4, j4) of the first search, and it can be determined whether the search result (i4, j4) meets the contour search end condition. If it does, the contour search is terminated, and the target contour only includes the contour starting point (i, j).
[0131] On the contrary, if the search result (i4, j4) does not meet the end condition of the contour search, it indicates that the search result (i4, j4) of the first search can be used as a boundary point constituting the target contour, that is, the search result (i4, j4) of the first search is a pixel point connected to the contour starting point and belongs to the target contour, and the next search of the cyclic search stage can be continued based on the search result (i4, j4) of the first search. Specifically, the center point (i3, j3) of the first search can be used as the starting boundary point (i2, j2) of the second search, and the search result (i4, j4) of the first search can be used as the center point (i3, j3) of the second search.
[0132] Thus, based on the starting boundary point (i2, j2) of the second search and the center point (i3, j3) of the second search, the binary image can be searched for the second time in the cyclic search phase to obtain the search result (i4, j4) of the second search, and it can be further determined whether the search result (i4, j4) of the second search meets the end condition of the contour search; if it does, the current contour search can be terminated to obtain the searched target contour; if it does not meet the end condition, the next search of the cyclic search phase can be continued based on the search result (i4, j4) of the second search, and so on, repeating the above steps until the search result (i4, j4) of the kth search of the cyclic search meets the end condition of the contour search, and the searched target contour can be obtained, and the target contour can be composed of the above contour starting point (i, j) (i.e., the first pixel point) and the search result obtained in each search in the cyclic search phase, and the first pixel point and the search result obtained in each search in the cyclic search phase are sequentially connected to each other. Wherein, k can be an integer greater than 1.
[0133] Among them, it should be noted that the implementation principle of each search in the cyclic search stage of the reverse search direction is the same. Here, the implementation process of the second search in the cyclic search stage is taken as an example for explanation: starting from the starting boundary point (i2, j2) of the second search, the first non-zero point in the neighborhood of the center point (i3, j3) of the second search can be found in a counterclockwise direction; specifically, the center point (i3, j3) of the second search can be the center point of the 8-neighborhood, and the next pixel point in the counterclockwise direction of the starting boundary point (i2, j2) of the second search can be used as the starting point, recorded as the coordinates (i2_jext, j2_jext), and the 8-neighborhood of the center point (i3, j3) of the second search can be searched counterclockwise from the pixel point (i2_jext, j2_jext), until the first non-zero value is found, and the first non-zero point can be used as the search result (i4, j4) of the second search.
[0134] Optionally, the contour search termination condition met by the search result (i4, j4) of any search in the cyclic search stage of the above-mentioned reverse search direction may include: the search result (i4, j4) obtained by any search is the same as the contour starting point (i, j), and the center point (i3, j3) of any search is the same as the starting search base point (i1, j1); that is, if the search result (i4, j4) of any search meets the contour search termination condition, it indicates that any search has returned to the contour starting point (i, j) of this contour search, that is, the starting point and boundary points of this contour search have formed a closed contour. Optionally, the target contour searched in the present application may be a closed-loop contour, or it may be an open curve. It is understandable that if the contour is an open curve, then when performing a contour search, after searching all the points on the contour for the first time, all the points on the contour may continue to be searched in the reverse order, so that it may also be possible to eventually return to the contour starting point (i, j) of this contour search.
[0135] Through the above process, the target contour is searched along the reverse search direction.
[0136] See also Figure 5a-Figure 5b , Figure 5a-Figure 5b is a schematic diagram of a reverse contour search scenario provided by an embodiment of the present application. Figure 5a For the binary image shown, in the initialization search phase, an exemplary process for determining the search base point (i1, j1) may include: the image search device may search for a pixel point with pixel coordinates (1, 2) from the binary image according to the judgment condition of the contour starting point in the reverse search direction (such as the above-mentioned contour starting search condition), as the contour starting point of the contour where the pixel point (1, 2) is located in the reverse search direction.
[0137] Furthermore, the left adjacent pixel point (1, 1) belonging to the same row as the starting point (1, 2) of the contour can be used as the starting boundary point (i2, j2), that is, the starting boundary point (i2, j2) = (1, 1), and the pixel value of the starting boundary point (i2, j2) can be 0.
[0138] Then, the contour starting point (1, 2) can be taken as the center point of the neighborhood, and starting from the starting boundary point (i2, j2), the first non-zero point (1, 3) in the neighborhood of the contour starting point (1, 2) can be found in a clockwise direction, and the first non-zero point (1, 3) can be used as the starting search base point (i1, j1), that is, the starting search base point (i1, j1) = (1, 3).
[0139] For example Figure 5bAs shown, the above-mentioned contour starting point (1, 2) can be used as the center point (i3, j3) of the neighborhood search in the first search of the cyclic search stage in the reverse search direction, and the above-mentioned starting search base point (i1, j1) = (1, 3) can be used as the starting boundary point (i2, j2) = (1, 3) in the first search of the cyclic search stage in the reverse search direction. Furthermore, the search result (i4, j4) = (2, 2) of the first search can be obtained by searching with the center point (i3, j3) and the starting boundary point (i2, j2).
[0140] Furthermore, since the above search result (i4, j4) = (2, 2) does not meet the end condition of the contour search in the reverse search direction, the second search in the circular search stage can be continued in the reverse search direction: in the second search, the above center point (i3, j3) = (1, 2) that can be searched for the first time can be used as the starting boundary point (i2, j2) of the second search, and the search result (i4, j4) = (2, 2) of the first search can be used as the center point (i3, j3) of the second search, and then, based on the center point (i3, j3) and the starting boundary point (i2, j2), the search result (i4, j4) = (3, 2) of the second search can be searched.
[0141] By analogy, since the search result (i4, j4) = (3, 2) does not meet the end condition of the contour search in the reverse search direction, the circular search stage can continue to search more times in the reverse search direction until the search result meets the end condition of the contour search in the reverse search direction, and the corresponding contour can be searched.
[0142] Furthermore, if the first search direction is a forward search direction, the process of searching along the forward search direction to obtain the above-mentioned target contour may include: similarly, in conjunction with the above-mentioned Table 1, the present application may, after searching for the starting point of the contour of the target in the first search direction (i.e., the first pixel point), perform an initialization search based on the first pixel point and then perform a cyclic search. Each search in the cyclic search may search for a pixel point on the target contour. Ultimately, the search results obtained through the first pixel point and each search in the cyclic search may constitute the entire target contour that has been searched, as described below.
[0143] Search phase 1 for the target contour in the forward search direction: Initialization search phase for the target contour in the forward search direction.
[0144] Similarly, the initialization search phase may be a phase for searching for the starting search base point (i1, j1). Among them, the contour starting point (i.e., the first pixel point) on the target contour searched from the binary image along the first search direction can be represented as the above-mentioned contour starting point (i, j), and then, based on the contour starting point (i, j), the starting boundary point (i2, j2) for the target contour in the forward search direction can be determined; specifically, if the outer boundary contour needs to be searched currently, the pixel point (i, j+1) in the binary image can be used as the starting boundary point (i2, j2), that is, the pixel point on the adjacent right side of the same row as the contour starting point (i, j) is used as the starting boundary point (i2, j2), and the pixel value of the pixel point (i, j+1) is 0; if the hole boundary contour needs to be searched currently, the pixel point (i, j-1) in the binary image can be used as the starting boundary point (i2, j2), that is, the pixel point on the adjacent left side of the same row as the contour starting point (i, j) is used as the starting boundary point (i2, j2), and the pixel value of the pixel point (i, j-1) is 0. Furthermore, the starting search base point (i1, j1) can be searched from the binary image through the contour starting point (i, j) and the starting boundary point (i2, j2). The starting search base point (i1, j1) can be used to find the reference point of the starting boundary point of the contour search when performing a subsequent forward contour search (i.e., a contour search in the forward search direction).
[0145] Among them, the specific process of determining the starting search base point (i1, j1) may include: starting from the starting boundary point (i2, j2) and searching for the starting search base point (i1, j1) in the neighborhood of the contour starting point (i, j) counterclockwise; specifically, it may be taking the contour starting point (i, j) as the center, starting from the starting boundary point (i2, j2) and rotating counterclockwise to find the first non-zero point in the neighborhood of the contour starting point (i, j), and use the first non-zero point as the starting search base point (i1, j1).
[0146] Search phase 2 for the target contour in the forward search direction: a cyclic search phase for the target contour along the forward search direction.
[0147] Similarly, the cyclic search phase for the target contour can be implemented based on the starting search base point (i1, j1) of the above-mentioned initialization search phase. Specifically, a cyclic search can be performed based on the starting search base point (i1, j1) and the contour starting point (i, j) to search for corresponding search results (i.e., the results of the neighborhood search). The search results obtained belong to the pixel points on the target contour. The cyclic search can have one or more searches until the search results meet the contour search end condition, then the contour search can be stopped and the corresponding contour searched (such as the target contour) can be obtained. The following content is described.
[0148] Specifically, the starting search base point (i1, j1) obtained in the initialization phase can be used as the starting boundary point (i2, j2) of the first search in the cyclic search phase, and the contour starting point (i, j) can be used as the center point (i3, j3) of the neighborhood search in the first search in the cyclic search phase. Then, based on the starting boundary point (i2, j2) and the center point (i3, j3) of the first search in the cyclic search phase, the binary image can be searched for the first time in the cyclic search phase to obtain the search result (i4, j4) of the first search, and it can be determined whether the search result (i4, j4) meets the contour search end condition. If it does, the contour search is terminated, and the target contour only includes the contour starting point (i, j).
[0149] On the contrary, if the search result (i4, j4) does not meet the end condition of the contour search, it indicates that the search result (i4, j4) of the first search can be used as a boundary point constituting the target contour, that is, the search result (i4, j4) of the first search is a pixel point connected to the contour starting point and belongs to the target contour, and the next search of the cyclic search stage can be continued based on the search result (i4, j4) of the first search. Specifically, the center point (i3, j3) of the first search can be used as the starting boundary point (i2, j2) of the second search, and the search result (i4, j4) of the first search can be used as the center point (i3, j3) of the second search.
[0150] Thus, based on the starting boundary point (i2, j2) of the second search and the center point (i3, j3) of the second search, the binary image can be searched for the second time in the cyclic search phase to obtain the search result (i4, j4) of the second search, and it can be further determined whether the search result (i4, j4) of the second search meets the end condition of the contour search; if it does, the current contour search can be terminated to obtain the searched target contour; if it does not meet the end condition, the next search of the cyclic search phase can be continued based on the search result (i4, j4) of the second search, and so on, repeating the above steps until the search result (i4, j4) of the kth search of the cyclic search meets the end condition of the contour search, and the searched target contour can be obtained, and the target contour can be composed of the above contour starting point (i, j) (i.e., the first pixel point) and the search result obtained in each search in the cyclic search phase, and the first pixel point and the search result obtained in each search in the cyclic search phase are sequentially connected to each other. Wherein, k can be an integer greater than 1.
[0151] Among them, it should be noted that the implementation principle of each search in the cyclic search stage in the forward search direction is the same. Here, the implementation process of the second search in the cyclic search stage is taken as an example for explanation: starting from the starting boundary point (i2, j2) of the second search, the first non-zero point in the neighborhood of the center point (i3, j3) of the second search can be found in a clockwise direction; specifically, the center point (i3, j3) of the second search can be the center point of the 8-neighborhood, and the next pixel point in the clockwise direction of the starting boundary point (i2, j2) of the second search can be used as the starting point, recorded as the coordinates (i2_jext, j2_jext), and the 8-neighborhood of the center point (i3, j3) of the second search can be searched clockwise from the pixel point (i2_jext, j2_jext) until the first non-zero value is found, and the first non-zero point can be used as the search result (i4, j4) of the second search.
[0152] Optionally, the contour search termination conditions met by the search result (i4, j4) of any search in the cyclic search stage in the forward search direction may include: the search result (i4, j4) obtained by any search is the same as the contour starting point (i, j), and the center point (i3, j3) of any search is the same as the starting search base point (i1, j1); that is, if the search result (i4, j4) of any search meets the contour search termination conditions, it indicates that any search has returned to the contour starting point (i, j) of this contour search, that is, the starting point and boundary points of this contour search have formed a closed contour.
[0153] Through the above process, the target contour is searched along the forward search direction.
[0154] After the above-mentioned target contour is obtained through search, the image search device can generate conversion data of the target contour, and the conversion data can include indication data respectively associated with each search direction except the first search direction, and the indication data can be used to indicate the target contour in the contour search of the associated search direction. Since the target contour can be any contour obtained by searching along the first search direction, any indication data associated with a search direction except the first search direction can be the indication data of the target contour in the search direction, and the indication data is used to indicate the target contour searched along the first search direction in the contour search of the search direction. That is, the target contour has an indication data in a search direction except the first search direction, and the indication data is used to indicate the target contour in the contour search of the search direction.
[0155] Therefore, the process of generating the conversion data of the target contour searched along the first search direction may include:
[0156] First, the image processing device can obtain the contour starting point of the target contour in each search direction except the first search direction in the binary image. It should be noted that the target contour has a contour starting point in each of the N search directions. The contour starting point of the target contour in a search direction may refer to the first (i.e., the first) pixel point on the target contour searched in the contour search in the search direction that meets the contour starting search condition in the search direction. In other words, the contour starting point of the target contour in a search direction may refer to the first pixel point belonging to the target contour searched along the search direction.
[0157] Optionally, any search direction other than the first search direction among the N search directions may be referred to as the second search direction. If the first search direction is a reverse search direction and the second search direction is a forward search direction, the contour starting point of the target contour in the second search direction may be obtained according to the following logic:
[0158] if(i4>i3)
[0159] (i5, j5) = (i4, j4) / / If i4 in the search result (i4, j4) of a certain search in the cyclic search phase of the reverse search direction is greater than i3 in the center point (i3, j3), then the search result (i4, j4) is used to update (can be an overwriting update) the conversion coordinates (i5, j5)
[0160] else if((i4==i3)&&(j4>j3))
[0161] (i5, j5) = (i4, j4) / / If i4 in the search result (i4, j4) of a certain search in the cyclic search phase of the reverse search direction is equal to i3 in the center point (i3, j3), and j4 in the search result (i4, j4) is greater than j3 in the center point (i3, j3), then the search result (i4, j4) is used to update (can be an overwriting update) the conversion coordinate (i5, j5)
[0162] Among them, through the above logic, in the process of searching for the target contour, the conversion coordinates (i5, j5) can be updated based on each pixel point searched on the target contour. The final updated conversion coordinates (i5, j5) are the pixel points at the bottom and rightmost (first satisfy the bottom, then satisfy the rightmost) on the target contour. This pixel point is the starting point of the target contour in the forward search direction.
[0163] The above process is a process of converting the contour starting point of the searched target contour in the forward search direction during the process of searching the target contour along the reverse search direction.
[0164] Furthermore, if the first search direction is a forward search direction and the second search direction is a reverse search direction, the contour starting point of the target contour in the second search direction can be obtained according to the following logic:
[0165] if(i4 <i3)
[0166] (i5, j5) = (i4, j4) / / If i4 in the search result (i4, j4) of a certain search in the cyclic search phase in the forward search direction is smaller than i3 in the center point (i3, j3), then the search result (i4, j4) is used to update (can be an overwriting update) the conversion coordinates (i5, j5)
[0167] else if((i4==i3)&&(j4 <j3))
[0168] (i5, j5) = (i4, j4) / / If i4 in the search result (i4, j4) of a certain search in the cyclic search phase in the forward search direction is equal to i3 in the center point (i3, j3), and j4 in the search result (i4, j4) is less than j3 in the center point (i3, j3), then the search result (i4, j4) is used to update (can be an overwriting update) the conversion coordinate (i5, j5)
[0169] Among them, through the above logic, in the process of searching for the target contour, the conversion coordinates (i5, j5) can be updated based on each pixel point searched on the target contour. The final updated conversion coordinates (i5, j5) are the pixel points at the top and leftmost side of the target contour (first satisfying the top and then the leftmost side). This pixel point is the starting point of the target contour in the reverse search direction.
[0170] The above process is a process of converting and obtaining the contour starting point of the searched target contour in the reverse search direction during the process of searching the target contour along the forward search direction.
[0171] After obtaining the starting point of the target contour in each search direction except the first search direction among N search directions, the image search device can generate indication data of the target contour in each search direction except the first search direction through the starting point of the target contour in the search direction except the first search direction: the image search device can obtain the pixel coordinates (including horizontal and vertical coordinates) of the starting point of the contour of the target contour in each search direction except the first search direction in the binary image, and then the image search device can use the pixel coordinates of the starting point of the contour of the target contour in each search direction except the first search direction as the indication data of the target contour in the search direction.
[0172] In other words, the indication data of the target contour in one search direction may be the pixel coordinates of the contour starting point of the target contour in the search direction.
[0173] Furthermore, the image search device can use the indication data of the target contour in each search direction except the first search direction as the conversion data of the target contour, and the conversion data includes the indication data of the target contour in each search direction except the first search direction.
[0174] See also Figure 6a-6b , Figure 6a-6b Schematic diagram of a scenario for determining a contour starting point provided by an embodiment of the present application. Figure 6a As shown, the starting point of the target contour in the binary image in the reverse search direction can be the top and leftmost pixel on the target contour. When the contour search is performed on the binary image along the reverse search direction, the top and leftmost pixel is the first pixel searched on the target contour.
[0175] Similarly, the starting point of the target contour in the binary image in the forward search direction can be the bottom and rightmost pixel on the target contour. When the binary image is searched for contour along the forward search direction, the bottom and rightmost pixel is the first pixel found on the target contour.
[0176] For example Figure 6b As shown, the contour search of the target image along the reverse search direction is to traverse and scan each row of pixels in the binary image from top to bottom and from left to right (such as scanning the first row of pixels from left to right → scanning the second row of pixels from left to right → scanning the third row of pixels from left to right...) to search for a pixel that meets the contour start search condition in the reverse search direction, and start searching the contour where the pixel is located from the pixel. For example, the pixel (1, 2) here can be a pixel that meets the contour start search condition in the reverse search direction.
[0177] Similarly, the contour search of the target image along the forward search direction is to traverse and scan each row of pixels in the binary image from bottom to top and from right to left (such as scanning the first to last row of pixels from right to left → scanning the second to last row of pixels from right to left → scanning the third to last row of pixels from right to left...) to search for a pixel point that meets the contour start search condition in the forward search direction, and start searching the contour where the pixel point is located from this pixel point. For example, the pixel point (4, 9) here can be a pixel point that meets the contour start search condition in the forward search direction.
[0178] Step S103, in the process of performing contour search on the target image, skip the contour search of the indicated contour associated with each of the N search directions, and obtain the contour searched along each of the N search directions; the indicated contour associated with the first search direction includes the contour indicated by the indication data associated with the first search direction.
[0179] Optionally, during the process of performing contour search on the target image along the above-mentioned N search directions, the image search device may skip the contour search of the indicative contour associated with each of the N search directions, thereby obtaining the contour searched along each of the N search directions.
[0180] The indicated contour associated with the first search direction may include the contour indicated by all the indication data associated with the first search direction. In other words, the indicated contour associated with the first search direction may include the contours searched in other search directions except the first search direction.
[0181] The target contour has an indication data in the second search direction. Therefore, here, a search process of skipping the target contour searched in the first search direction in the second search direction is specifically described as an example. The process may include:
[0182] When a second pixel point that meets the contour start search condition in the second search direction is searched along the second search direction, and it is detected that the second pixel point belongs to the pixel point (such as the first pixel point) indicated by the indication data associated with the second search direction (such as the indication data belonging to the target contour in the second search direction) (such as when the second pixel point is the first pixel point), the image search device can skip the process of contour search based on the second pixel point in the second search direction, that is, the contour where the second pixel point is located is not searched from the second pixel point. In addition, the image search device can also obtain each pixel point on the target contour through the indication data of the target contour in the second search direction, and can also skip the process of contour search based on each pixel point on the target contour except the second pixel point in the second search direction, so that the target contour where each pixel point is located can be searched without starting from each pixel point on the target contour, that is, the process of contour search based on each pixel point on the target contour that has been searched along the first search direction is skipped in the second search direction.
[0183] Among them, the process of the image search device obtaining each pixel point on the target contour (i.e., obtaining a set of pixel points on the target contour) through the indication data of the target contour in the second search direction may include: when the image search device searches for the target contour along the first search direction or after searching for the target contour, the image search device can obtain the pixel coordinates of each pixel point on the target contour in the binary image.
[0184] Furthermore, the image search device can use the indication data of the target contour in the second search direction to associate and record the pixel coordinates of each pixel point on the target contour. That is, it can be understood that the pixel coordinates of the contour starting point of the target contour in the second search direction can be used as the contour identification of the target contour in the second search direction, that is, the target contour is identified by the indication data of the target contour in the second search direction, and the pixel coordinates of each pixel point on the identified target contour can be recorded.
[0185] In other words, when the target contour is found in the first search direction, the pixel coordinates of each pixel point on the target contour can be associated and recorded by generating indication data for the second search direction based on the target contour, that is, the set of each pixel point on the target contour can be associated and recorded.
[0186] Therefore, later, when the second pixel point on the target contour is searched in the second search direction, the pixel coordinates of each pixel point on the target contour previously recorded by associating the indicator data of the target contour in the second search direction (such as the pixel coordinates of the second pixel point) can be obtained (such as each pixel point on the target contour except the second pixel point can be obtained through this process). It can be understood that obtaining the pixel coordinates of each pixel point on the target contour is to obtain each pixel point on the target contour.
[0187] From the above-described related features, it can be understood that the first pixel point is not the pixel point indicated by the indication data associated with the first search direction, and is not the pixel point on the contour where the pixel point indicated by the indication data associated with the first search direction is located. It can also be understood that when the first pixel point is searched along the first search direction, the pixel point on the target contour that meets the contour starting search condition of the corresponding search direction should not be searched in other search directions, that is, the contour where the first pixel point is located has not been searched in other search directions.
[0188] Therefore, by skipping the search process of the indicated contour associated with each of the N search directions, in the contour search in each search direction, the same contour will not be searched repeatedly in different search directions, thereby improving the efficiency of contour searching for the target image using multiple search directions and ensuring the search integrity and consistency of the contour in the target image.
[0189] Wherein, whenever a contour is found in a search direction, each row of pixels in the binary image can be scanned again along the search direction from the very beginning (e.g., for the reverse search direction, the very beginning position is the position at the 1st row and the 1st column; for the forward search direction, the very beginning position is the position at the 1st to last row and the 1st to last column) to find the pixel points that meet the contour starting search condition in the search direction and do not belong to the contours that have been searched in each search direction (including all search directions) as the contour starting point to continue searching for the next contour in the search direction, and so on. On this basis, it can be understood that when a contour starting point for starting a contour search cannot be found in a search direction (e.g., a contour starting point that meets the contour starting search condition in the search direction other than the pixel points on the contours that have been searched in each search direction (including the search direction itself) cannot be found), it indicates that the contour search in the search direction has been completed, that is, it indicates that the contour search in the search direction has been completely ended.
[0190] Among them, the contours searched in the binary image of the target image can be understood as the contours searched in the target image, and the contours in the target image may include all contours searched along the above N search directions.
[0191] After searching for the contour in the target image, the contour searched for the target image can be marked in the target image (it can be any marking method, such as highlighting, or highlighting, etc.), and the image within the marked contour can be segmented (such as cropping) in the target image. This image is a local image in the target image. Depending on the actual application scenario, the local image may also be different. For example, the local image may be a foreground image in the target image, an image of the target object, or an image of a target area (such as an area of a specific biological organ in the medical field), etc., which can be determined based on the actual application scenario.
[0192] Among them, identifying the contour obtained by searching the target image in the target image may include: since there is a one-to-one correspondence between the pixel points in the target image and the pixel points in the binary image, such as the pixel coordinates of a pixel point in the target image and the pixel coordinates of the pixel point obtained after binarization of the pixel point in the binary image are the same, therefore, after the image search device searches for the corresponding contour in the binary image along N search directions, the contour can be correspondingly identified in the target image according to the pixel coordinates of each pixel point on the contour in the binary image, and the pixel coordinates of each pixel point on the contour identified in the target image are the same as the pixel coordinates of each pixel point of the contour in the binary image, that is, through a pixel point on the contour searched in the binary image, the pixel point corresponding to the pixel point in the target image (the pixel point with the same pixel coordinates) can be identified, and in this way, the corresponding pixel points in the target image can be identified through each pixel point on the contour, and the contour can be identified in the target image.
[0193] See also Figure 7 , Figure 7 Schematic diagram of an image segmentation scenario provided by an embodiment of the present application. Figure 7 As shown, the target image can be searched for contours according to the method provided in the present application, the contour of the puppy in the target image can be searched and obtained, and the contour of the puppy can be identified in the target image, and then, the local image within the identified contour can be segmented in the target image, and the local image is the local image where the puppy is located in the target image.
[0194] The present application can perform contour search on a target image along N search directions; N is an integer greater than 1; and conversion data of contours searched along each of the N search directions can be obtained; any search direction among the N search directions is a first search direction, and the conversion data of contours searched along the first search direction include indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction; and, in the process of performing contour search on the target image, contour search for indicated contours corresponding to each of the N search directions can be skipped in each of the N search directions to obtain contours searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction; wherein, the contour in the target image includes the contours searched along the N search directions. It can be seen that the method proposed in the present application can perform contour search on the target image along multiple search directions (i.e., N search directions) at the same time, and in the process of performing contour search along multiple search directions, in each search direction, the contour search of the contour that has been searched in other search directions can be skipped through the associated indication information, so that the same contour in the target image will not be searched repeatedly in each search direction, thereby greatly improving the efficiency of searching for contours in the target image.
[0195] Based on the above detailed description of the image search method, the following describes the various units that implement the image search method. Figure 8 , Figure 8 is a schematic diagram of the structure of an image search device provided in an embodiment of the present application. Figure 8 As shown, the structure may include a forward contour search unit, a forward contour boundary conversion unit corresponding to the forward contour search unit, a reverse contour search unit, a reverse contour boundary conversion unit corresponding to the reverse contour search unit, and a scanning status query unit. The image processing method provided in the present application can be deployed in an image processing device, and the image processing device is run by a computer device to implement the image processing method. Therefore, each unit in the structure can be deployed in the image processing device.
[0196] Among them, the forward contour search unit is used to perform contour search on the target image along the above-mentioned forward search direction, so as to obtain the corresponding contour in the target image from the forward search direction, and the reverse contour search unit is used to perform contour search on the target image along the above-mentioned reverse search direction, so as to obtain the corresponding contour in the target image from the reverse search direction.
[0197] The forward contour boundary conversion unit corresponding to the forward contour search unit can be used to perform boundary conversion processing on the contour searched by the forward contour search unit (i.e., the contour searched along the forward search direction) to obtain conversion data of the contour searched by the forward contour search unit. The conversion data may include indication data associated with the reverse search direction. The indication data may be used to indicate the contour searched by the forward contour search unit in the contour search in the reverse search direction. The conversion data may be stored in the scanning status query unit, and the pixel coordinates of each pixel point on the contour searched by the forward contour search unit may also be stored in the scanning status query unit.
[0198] Similarly, the reverse contour boundary conversion unit corresponding to the reverse contour search unit can be used to perform boundary conversion processing on the contour searched by the reverse contour search unit (i.e., the contour searched along the forward search direction) to obtain conversion data of the contour searched by the reverse contour search unit. The conversion data can include indication data associated with the forward search direction, and the indication data can be used to indicate the contour searched by the reverse contour search unit in the contour search in the forward search direction. The conversion data can be stored in the scanning status query unit, and the pixel coordinates of each pixel point on the contour searched by the reverse contour search unit can also be stored in the scanning status query unit.
[0199] Furthermore, it can be understood that, in the process of the forward contour search unit scanning the pixel points in the binary image to perform contour search, a query can be performed in the scanning status query unit based on the scanned (i.e., searched) pixel points that meet the contour starting search conditions in the forward search direction to determine whether the scanned pixel point is included in the scanning status query unit. If so, the contour search is not started with the currently scanned pixel point as the contour starting point. If not, the contour search is started with the currently scanned pixel point as the contour starting point.
[0200] Similarly, in the process of the reverse contour search unit scanning the pixel points in the binary image for contour search, a query can be performed in the scanning status query unit based on the scanned (i.e., searched) pixel points that meet the contour starting search conditions in the reverse search direction to determine whether the scanned pixel point is included in the scanning status query unit. If so, the contour search is not started with the currently scanned pixel point as the contour starting point. If not, the contour search is started with the currently scanned pixel point as the contour starting point.
[0201] When the forward contour search unit cannot find a pixel point in the binary image that meets the contour start search condition in the forward search direction and is not included in the scanning state query unit, the forward contour search unit has completed the contour search of the binary image and can be ended. Similarly, when the reverse contour search unit cannot find a pixel point in the binary image that meets the contour start search condition in the reverse search direction and is not included in the scanning state query unit, the reverse contour search unit has completed the contour search of the binary image and can be ended.
[0202] Through the above-mentioned units, each contour in the target image can be searched along the reverse search direction and the forward search direction at the same time. From the above, it can be seen that the forward / reverse contour boundary conversion unit and the scanning status query unit provided by the present application are a new technology, so that contour search will not be performed based on the pixel points on the searched contour in each search direction, avoiding repeated contour search and ensuring the integrity of the contour search in the image. And based on the support of the forward / reverse contour boundary conversion unit and the scanning status query unit, it is possible to perform parallel searches for different contours in the target image along multiple search directions at the same time on the basis of ensuring the correctness of the contour search, which greatly improves the speed and efficiency of the contour search for the target image and improves the contour search performance.
[0203] See also Fig. 9 , Fig. 9 is a schematic diagram of the structure of another image search device provided in an embodiment of the present application. Fig. 9 As shown, the image search device 1 may include: a search module 11 and an acquisition module 12 .
[0204] A search module 11 is used to perform contour search on the target image along N search directions, where N is an integer greater than 1;
[0205] An acquisition module 12 is used to acquire conversion data of contours searched along each of N search directions; any search direction among the N search directions is a first search direction, and the conversion data of the contours searched along the first search direction includes indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction;
[0206] The search module 11 is further configured to skip the contour search of the indicated contour corresponding to each of the N search directions in the process of performing contour search on the target image, and obtain the contour searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction;
[0207] The contours in the target image include contours searched along N search directions.
[0208] Optionally, the search module 11 performs contour search on the target image along N search directions, including:
[0209] Performing binarization processing on the target image to obtain a binary image of the target image;
[0210] Perform contour search on the binary image along N search directions.
[0211] Optionally, the process of the search module 11 performing contour search on the binary image along the first search direction includes:
[0212] Searching pixel points in the binary image in sequence along a first search direction;
[0213] When the first pixel point is searched, a contour search is performed based on the first pixel point to search for a target contour where the first pixel point is located;
[0214] The first pixel point refers to a pixel point that meets the contour start search condition in the first search direction.
[0215] Optionally, a contour searched along the first search direction has a conversion data, the target contour is any contour searched along the first search direction, and any indication data associated with a search direction other than the first search direction is the indication data of the target contour in the search direction;
[0216] The process of the acquisition module 12 generating the conversion data of the target contour searched along the first search direction includes:
[0217] In the binary image, obtaining the contour starting point of the target contour in each search direction except the first search direction;
[0218] Based on the contour starting point of the target contour in each search direction except the first search direction, generating indication data of the target contour in each search direction;
[0219] Determine the indication data of the target contour in each search direction except the first search direction as the conversion data of the target contour;
[0220] Among them, the target contour has a contour starting point in each of the N search directions, and the contour starting point of the target contour in a search direction refers to the first pixel point on the target contour searched in the contour search in the search direction that meets the contour starting search conditions in the search direction.
[0221] Optionally, the acquisition module 12 generates indication data in each search direction based on the contour starting point of the target contour in each search direction except the first search direction, including:
[0222] Obtaining pixel coordinates of the starting points of the target contour in each search direction except the first search direction in the binary image;
[0223] The pixel coordinates of the starting point of the target contour in each search direction except the first search direction are determined as the indication data of the target contour in the respective search directions.
[0224] Optionally, any search direction among the N search directions except the first search direction is a second search direction;
[0225] The search module 11 skips the contour search of the indicated contour corresponding to each of the N search directions in the process of performing contour search on the target image, and obtains the contour searched along each of the N search directions in a manner including:
[0226] When a second pixel point that meets the contour start search condition in the second search direction is searched along the second search direction, and it is detected that the second pixel point belongs to the pixel point indicated by the indication data of the target contour in the second search direction, the contour search process based on the second pixel point is skipped in the second search direction; and
[0227] Based on the indication data of the target contour in the second search direction, each pixel point on the target contour is obtained, and in the second search direction, the contour search process based on each pixel point on the target contour except the second pixel point is skipped.
[0228] Optionally, when or after searching for the target contour along the first search direction, the device 1 is further used to:
[0229] Obtain the pixel coordinates of each pixel point on the searched target contour in the binary image;
[0230] Using the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour are recorded in association;
[0231] Based on the indication data of the target contour in the second search direction, each pixel point on the target contour is obtained, including:
[0232] Based on the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour of the associated record are obtained.
[0233] Optionally, the pixel value of the pixel point in the binary image is a first pixel value or a second pixel value, and the first pixel value is greater than the second pixel value;
[0234] The target contour is a hole boundary type or an outer boundary type. If the target contour is a hole boundary type, the pixel values of the pixels within the target contour are all the second pixel values;
[0235] If the target contour is an outer boundary type, the pixel values of the pixel points within the target contour are all first pixel values, and the pixel values of the pixel points outside the target contour and adjacent to the target contour are second pixel values.
[0236] Optionally, the first search direction is a reverse search direction or a forward search direction; the reverse search direction refers to a direction of searching for pixel points that meet the contour start search condition in the first search direction in the binary image from left to right and from top to bottom, and the forward search direction refers to a direction of searching for pixel points that meet the contour start search condition in the first search direction in the binary image from right to left and from bottom to top;
[0237] Wherein, the first pixel is represented as (i, j), the pixel value of the first pixel is represented as f(i, j), i is the longitudinal coordinate of the first pixel in the binary image, j is the transverse coordinate of the first pixel in the binary image, and both i and j are non-negative integers;
[0238] If the target contour is a hole boundary type, and the first search direction is a reverse search direction, the initial search condition for the contour in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value;
[0239] If the target contour is a hole boundary type, and the first search direction is a forward search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value;
[0240] If the target contour is an outer boundary type, and the first search direction is a reverse search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value;
[0241] If the target contour is an outer boundary type and the first search direction is a forward search direction, the contour starting search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value.
[0242] Optionally, the search module 11 performs contour search based on the first pixel point to search for a target contour where the first pixel point is located, including:
[0243] In the binary image, starting from the first pixel point, searching for a plurality of pixel points that are connected in series and whose pixel values are all the first pixel value;
[0244] Based on the first pixel point and the searched multiple pixel points, a searched target contour is determined.
[0245] Optionally, the device 1 is also used for:
[0246] In the target image, the contour searched for the target image is identified;
[0247] In the target image, an image within the identified contour is segmented; the image belongs to a local image in the target image.
[0248] According to one embodiment of the present application, Figure 3 The steps involved in the image search method shown can be represented by Fig. 9 The image search device 1 shown in the figure is executed by each module. For example, Figure 3 The step S101 shown in FIG. 1 can be performed by Fig. 9 The search module 11 is used to perform, Figure 3 The step S102 shown in FIG. 1 can be performed by Fig. 9 The acquisition module 12 is executed; Figure 3 The step S103 shown in FIG. 1 can be performed by Fig. 9 The search module 11 is used to execute.
[0249] The present application can perform contour search on a target image along N search directions; N is an integer greater than 1; and conversion data of contours searched along each of the N search directions can be obtained; any search direction among the N search directions is a first search direction, and the conversion data of contours searched along the first search direction include indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction; and, in the process of performing contour search on the target image, contour search for indicated contours corresponding to each of the N search directions can be skipped in each of the N search directions to obtain contours searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction; wherein, the contour in the target image includes the contours searched along the N search directions. It can be seen that the device proposed in the present application can perform contour search on the target image along multiple search directions (i.e., N search directions) at the same time, and in the process of performing contour search along multiple search directions, in each search direction, the contour search of the contour that has been searched in other search directions can be skipped through the associated indication information, so that the same contour in the target image will not be searched repeatedly in each search direction, thereby greatly improving the efficiency of searching for contours in the target image.
[0250] According to one embodiment of the present application, Fig. 9 The various modules in the image search device 1 shown can be individually or all combined into one or several units to constitute, or one (some) of the units can be further divided into multiple functionally smaller sub-units, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In actual applications, the functions of one module can also be implemented by multiple units, or the functions of multiple modules can be implemented by one unit. In other embodiments of the present application, the image search device 1 may also include other units. In actual applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0251] According to one embodiment of the present application, a computer program capable of executing the steps involved in the corresponding methods shown in the embodiments of the present application can be run on a general-purpose computer device (the computer device may include processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM)) to construct the following. Fig. 9 The image search apparatus 1 shown in FIG. The computer program may be recorded on a computer-readable recording medium, and may be loaded into the computer device through the computer-readable recording medium and run therein.
[0252] See also Fig.10 , Fig.10 Schematic diagram of the structure of a computer device provided by this application. Fig.10 As shown, the computer device 1000 may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, in some embodiments, the computer device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Fig.10 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0253] exist Fig.10 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0254] Perform contour search on the target image along N search directions; N is an integer greater than 1;
[0255] Acquire conversion data of contours searched along each of N search directions; any one of the N search directions is a first search direction, and the conversion data of contours searched along the first search direction includes indication data respectively associated with each of the search directions except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction;
[0256] In the process of performing contour search on the target image, the contour search of the indicated contour associated with each of the N search directions is skipped to obtain the contour searched along each of the N search directions; the indicated contour associated with the first search direction includes the contour indicated by the indication data associated with the first search direction;
[0257] The contours in the target image include contours searched along N search directions.
[0258] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the above-mentioned image search method in each embodiment of the present application, and can also execute the above-mentioned Fig. 9 The description of the above-mentioned image search device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here either.
[0259] In addition, it should be pointed out here that: the present application also provides a computer-readable storage medium, and a computer program is stored in the computer-readable storage medium. When the processor executes the computer program, the description of the image search method in each embodiment of the present application can be executed. Therefore, it will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated. For technical details not disclosed in the computer storage medium embodiment involved in the present application, please refer to the description of the method embodiment of the present application.
[0260] As an example, the above-mentioned computer program may be deployed on one computer device for execution, or deployed on multiple computer devices located at one location for execution, or executed on multiple computer devices distributed at multiple locations and interconnected by a communication network. Multiple computer devices distributed at multiple locations and interconnected by a communication network may constitute a blockchain network.
[0261] The computer-readable storage medium may be an internal storage unit of the computer device, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit and an external storage device of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0262] The present application provides a computer program product, which includes a computer program, which is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the description of the above-mentioned image search method in each embodiment of the present application, and therefore, it will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in the present application, please refer to the description of the method embodiment of the present application.
[0263] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.
[0264] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0265] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. An image search method, characterized in that: The method comprises: Perform contour search on the target image along N search directions; N is an integer greater than 1; Acquire conversion data of contours searched along each of the N search directions; any one of the N search directions is a first search direction, and the conversion data of contours searched along the first search direction includes indication data respectively associated with each search direction except the first search direction, and the indication data is used to indicate the contours searched along the first search direction in the contour search in the associated search direction; In the process of performing contour search on the target image, in each of the N search directions, a contour search of the indicated contour associated with each of the search directions is skipped to obtain the contour searched along each of the N search directions; the indicated contour associated with the first search direction includes the contour indicated by the indication data associated with the first search direction; The contours in the target image include contours searched along the N search directions.
2. The method according to claim 1, characterized in that The contour search of the target image along N search directions includes: Performing binarization processing on the target image to obtain a binary image of the target image; A contour search is performed on the binary image along the N search directions.
3. The method according to claim 2, characterized in that The process of performing contour search on the binary image along the first search direction includes: Searching pixel points in the binary image in sequence along the first search direction; When the first pixel point is searched, a contour search is performed based on the first pixel point to search for a target contour where the first pixel point is located; The first pixel point refers to a pixel point that meets the contour start search condition in the first search direction.
4. The method according to claim 3, characterized in that A contour searched along the first search direction has a conversion data, the target contour is any contour searched along the first search direction, and any indication data associated with a search direction other than the first search direction is the indication data of the target contour in the search direction; The process of generating conversion data of the target contour searched along the first search direction includes: In the binary image, obtaining a contour starting point of the target contour in each search direction except the first search direction; Based on the contour starting point of the target contour in each search direction except the first search direction, generating indication data of the target contour in each search direction; Determine the indication data of the target contour in each search direction except the first search direction as the conversion data of the target contour; Among them, the target contour has a contour starting point in each of the N search directions, and the contour starting point of the target contour in a search direction refers to the first pixel point on the target contour searched in the contour search in the search direction that meets the contour starting search conditions in the search direction.
5. The method according to claim 4, characterized in that The step of generating indication data in each search direction based on the contour starting point of the target contour in each search direction except the first search direction comprises: Obtaining pixel coordinates of the starting points of the contour of the target in each search direction except the first search direction in the binary image; The pixel coordinates of the starting point of the target contour in each search direction except the first search direction are determined as the indication data of the target contour in each search direction.
6. The method according to claim 4, characterized in that Any search direction among the N search directions except the first search direction is a second search direction; In the process of performing contour search on the target image, in each of the N search directions, the contour search of the indicated contour corresponding to the respective search directions is skipped to obtain the contour searched along each of the N search directions, including: When a second pixel point that meets the contour start search condition in the second search direction is searched along the second search direction, and it is detected that the second pixel point belongs to the pixel point indicated by the indication data of the target contour in the second search direction, skipping the contour search based on the second pixel point in the second search direction; and, Based on the indication data of the target contour in the second search direction, each pixel point on the target contour is obtained, and in the second search direction, the process of performing contour search based on each pixel point on the target contour except the second pixel point is skipped.
7. The method according to claim 6, characterized in that When the target contour is searched along the first search direction or after the target contour is searched, the method further includes: Obtaining the pixel coordinates of each pixel point on the searched target contour in the binary image; Using the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour are recorded in association; The acquiring each pixel point on the target contour based on the indication data of the target contour in the second search direction comprises: Based on the indication data of the target contour in the second search direction, the pixel coordinates of each pixel point on the target contour of the associated record are obtained.
8. The method according to claim 3, characterized in that A pixel value of a pixel point in the binary image is a first pixel value or a second pixel value, and the first pixel value is greater than the second pixel value; The target contour is a hole boundary type or an outer boundary type. If the target contour is the hole boundary type, the pixel values of the pixel points within the target contour are all the second pixel values; If the target contour is of the outer boundary type, the pixel values of the pixel points within the target contour are all the first pixel values, and the pixel values of the pixel points outside the target contour and adjacent to the target contour are the second pixel values.
9. The method according to claim 8, characterized in that The first search direction is a reverse search direction or a forward search direction; the reverse search direction refers to a direction of searching for pixels that meet the contour start search condition in the first search direction in the binary image from left to right and from top to bottom, and the forward search direction refers to a direction of searching for pixels that meet the contour start search condition in the first search direction in the binary image from right to left and from bottom to top; The first pixel is represented by (i, j), the pixel value of the first pixel is represented by f(i, j), i is the longitudinal coordinate of the first pixel in the binary image, j is the transverse coordinate of the first pixel in the binary image, and both i and j are non-negative integers; If the target contour is the hole boundary type, and the first search direction is the reverse search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value; If the target contour is the hole boundary type, and the first search direction is the forward search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value; If the target contour is the outer boundary type, and the first search direction is the reverse search direction, the contour start search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j-1) is equal to the second pixel value; If the target contour is the outer boundary type and the first search direction is the forward search direction, the contour starting search condition in the first search direction is: f(i, j) is equal to the first pixel value, and f(i, j+1) is equal to the second pixel value.
10. The method according to claim 8, characterized in that The performing contour search based on the first pixel point to search for a target contour where the first pixel point is located includes: In the binary image, starting from the first pixel point, searching for a plurality of pixel points that are connected in series and whose pixel values are all the first pixel value; The searched target contour is determined based on the first pixel point and the searched multiple pixel points.
11. The method according to claim 1, characterized in that: The method further comprises: In the target image, identifying the contour searched for the target image; In the target image, an image within the identified contour is segmented; the image belongs to a local image in the target image.
12. An image search device, characterized in that: The device comprises: A search module, used for performing contour search on a target image along N search directions; N is an integer greater than 1; an acquisition module, configured to acquire conversion data of contours searched along each of the N search directions; any one of the N search directions being a first search direction, and the conversion data of contours searched along the first search direction comprising indication data respectively associated with each of the search directions except the first search direction, the indication data being used to indicate the contours searched along the first search direction in the contour search in the associated search direction; The search module is further configured to, during the process of performing contour search on the target image, skip the contour search of the indicated contour corresponding to each of the N search directions, and obtain the contour searched along each of the N search directions; the indicated contour corresponding to the first search direction includes the contour indicated by the indication data associated with the first search direction; The contours in the target image include contours searched along the N search directions.
13. A computer program product, comprising a computer program, which implements the steps of the method according to any one of claims 1 to 11 when executed by a processor.
14. A computer device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 11.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Image contour searching method and device, server and medium
CN112733868A
Image processing device and method
JP2013061738A
