A method, device, storage medium and electronic device for contour tracking
By identifying and combining the pixel types and cluster numbers of image pixel points, the contour fragment collection is generated, which solves the problems of slow computing speed and low accuracy in traditional contour tracking technology, and achieves efficient and stable contour tracking effect.
Patent Information
- Application Number
- CN202510571915.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-05-06
AI Technical Summary
Traditional contour tracking technology requires processing all pixels of an image, including redundant background pixels and object pixels, resulting in slow calculation speed, inability to accurately track internal angle contour pixels, and poor algorithm stability.
By identifying the pixel type and current cluster number of the image pixel point, a collection of all contour segments is generated. Using the pixel vector dimensionality and cluster number characteristics, adjacent contour segments are merged and pseudo-contour pixels are cleared to ensure that all contour pixels are 100% tracked.
Improve the accuracy and efficiency and stability of contour tracking, ensure the integrity of calculation rate and contour tracking, and avoid redundant computing and memory waste.
Smart Images

Figure CN120088291B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of contour recognition technology. Specifically, it relates to a method, device, storage medium and electronic device for contour tracking. Background Art
[0002] A contour is one of the basic features of an object, which represents the basic shape of the object. Contour tracking is a basic task in image processing and computer vision. The accuracy and reliability of the contour tracking results will directly affect the understanding of the objective world, and the efficiency of contour tracking determines its practicality.
[0003] Traditional contour tracking techniques (such as: SBF, MSBF, ISBF, MNT, RSA, TPA or FCTA) need to process all pixels of the image, including redundant background pixels and object pixels. During the process of contour tracking and recognition, it implements a tracking process for each contour one by one. That is, it enters the next contour tracking only after one contour tracking is completed. And every time it enters a contour tracking process, it will disrupt the scanning process of the entire image, and each contour tracking process is a small loop, resulting in a slow calculation speed. Moreover, the above-mentioned contour tracking techniques cannot track the inner corner contour pixels, making it difficult to guarantee the accuracy of contour tracking.
[0004] Therefore, how to provide a technical solution for a contour tracking method with high efficiency and high precision has become a technical problem that urgently needs to be solved. Summary of the Invention
[0005] Some embodiments of this application aim to provide a method, device, storage medium and electronic device for contour tracking. Through the technical solutions of the embodiments of this application, the accuracy and efficiency of contour tracking can be improved, and at the same time, the stability of contour tracking is enhanced.
[0006] In a first aspect, some embodiments of the present application provide a method for contour tracking, including: identifying each pixel point in image pixels to determine the pixel type and current cluster number of each pixel point; wherein, the pixel type includes: contour pixels, pseudo - contour pixels, background pixels, and internal entity pixels; each pixel point is characterized by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel point; the current cluster number is obtained after updating the initial cluster number; generating a set storing all contour segments based on the pixel type and the current cluster number of each pixel point; the set storing all contour segments includes: contour segment sets of at least one object; each object's contour segment set in the contour segment sets of the at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour segment; the second subset includes the cluster numbers of all adjacent contour segments of the contour segment; merging the contour segments included in each object according to each object's contour segment set to obtain a complete contour and the final cluster number of each pixel point in the complete contour.
[0007] Some embodiments of the present application generate a set storing all contour segments through the pixel type and the current cluster number of each pixel point in image pixels, and then perform a merging process according to the contour segments in each object in the set storing all contour segments to obtain the final complete contour and the final cluster number. Some embodiments of the present application can achieve accurate identification and tracking of the contour of an object, with high efficiency and good stability.
[0008] In some embodiments, the identifying each pixel point in image pixels to determine the pixel type and current cluster number of each pixel point includes: determining the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point; using the first non - zero cluster number detected in sequence among the upper Moore neighborhood pixel points as the current cluster number of each pixel point.
[0009] Some embodiments of the present application can achieve accurate identification of pixel types by analyzing the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel, determining whether it is a contour pixel and updating its cluster number.
[0010] In some embodiments, determining the pixel type of each pixel point based on the cluster numbers of the upper Moore neighborhood pixel points and the pixel values of the lower Moore neighborhood pixel points of each pixel point includes: if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and the number of non-zero cluster numbers is less than two, then the any pixel point is a contour pixel; if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are two or more non-zero cluster numbers, then the any pixel point is a pseudo-contour pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point are all non-zero, then the any pixel point is an internal entity pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point have zero values, then the any pixel point is a contour pixel, otherwise it is an internal entity pixel.
[0011] Some embodiments of the present application can achieve accurate judgment of pixel points by analyzing the cluster numbers of upper Moore neighborhood pixel points and the pixel values of lower Moore neighborhood pixel points to determine the pixel type of any pixel point.
[0012] In some embodiments, when all the upper Moore neighborhood pixel points are zero cluster numbers, add one to the previously determined maximum cluster number as the current cluster number.
[0013] In some embodiments, merging the contour segments contained in each object according to the contour segment set of each object to obtain a complete contour and the final cluster number of each pixel point in the complete contour includes: repeatedly performing the following operations until the complete contour is obtained: according to a preset rule, merge two adjacent contour segments containing the same pseudo-contour pixel among adjacent contour segments, clear the pseudo-contour pixel, and update the cluster number of the maximum value among the cluster numbers of the pixel points contained in the adjacent contour segments to the cluster number of the contour pixel of the merged contour segment.
[0014] Some embodiments of the present application achieve accurate merging between contours and effective tracking of the complete contour by performing merging processing on adjacent contour segments and updating pixel cluster numbers.
[0015] Second aspect, some embodiments of the present application provide an apparatus for contour tracking, including: an identification module, configured to identify each pixel point in the image pixels to determine the pixel type and the current cluster number of each pixel point; wherein, the pixel type includes: contour pixels, pseudo-contour pixels, background pixels, and internal entity pixels; each pixel point is represented by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel point; the current cluster number is obtained by updating the initial cluster number; a generation module, configured to generate a set storing all contour segments based on the pixel type and the current cluster number of each pixel point; the set storing all overall contour segments includes: contour segment sets of at least one object; each object's contour segment set in the contour segment sets of the at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour segment; the second subset includes the cluster numbers of all adjacent contour segments of the contour segment; a merging module, configured to merge the contour segments included in each object according to each object's contour segment set to obtain a complete contour and the final cluster number of each pixel point in the complete contour.
[0016] In some embodiments, the identification module is configured to: determine the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point; use the first non-zero cluster number detected in sequence among the upper Moore neighborhood pixel points as the current cluster number of each pixel point.
[0017] In some embodiments, the identification module is configured to: if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel; if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are two or more non-zero cluster numbers, then the any pixel point is a pseudo-contour pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point are all non-zero, then the any pixel point is the internal entity pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel value of the lower Moore neighborhood pixel point of any pixel point has a zero value, then the any pixel point is a contour pixel, otherwise it is the internal entity pixel.
[0018] Third aspect, some embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any embodiment of the first aspect can be implemented.
[0019] Fourth aspect, some embodiments of the present application provide an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the method described in any one of the embodiments of the first aspect can be implemented.
[0020] Fifth aspect, some embodiments of the present application provide a computer program product, the computer program product includes a computer program, wherein when the computer program is executed by a processor, the method described in any one of the embodiments of the first aspect can be implemented. Description of the Drawings
[0021] To more clearly illustrate the technical solutions of some embodiments of the present application, the following will briefly introduce the drawings required to be used in some embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and thus should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative efforts.
[0022] Figure 1 One of the method flowcharts of contour tracing provided for some embodiments of the present application;
[0023] Figure 2 Schematic diagram of pixel distribution provided for some embodiments of the present application;
[0024] Figure 3 Schematic diagram of the contour of a complex connected region provided for some embodiments of the present application;
[0025] Figure 4 One of the schematic diagrams of contour segment merging provided for some embodiments of the present application;
[0026] Figure 5 Two of the schematic diagrams of contour segment merging provided for some embodiments of the present application;
[0027] Figure 6 Three of the schematic diagrams of contour segment merging provided for some embodiments of the present application;
[0028] Figure 7 Four of the schematic diagrams of contour segment merging provided for some embodiments of the present application;
[0029] Figure 8 Five of the schematic diagrams of contour segment merging provided for some embodiments of the present application;
[0030] Figure 9 Schematic diagram of the complete contour provided for some embodiments of the present application;
[0031] Figure 10The second flowchart of the contour tracking method provided for some embodiments of the present application;
[0032] Figure 11 The block diagram of the device for contour tracking provided for some embodiments of the present application;
[0033] Figure 12 The schematic diagram of an electronic device provided for some embodiments of the present application. Detailed implementation manners
[0034] Next, the technical solutions in some embodiments of the present application will be described in conjunction with the accompanying drawings in some embodiments of the present application.
[0035] It should be noted that: similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0036] Traditional methods adopt a strategy of tracing contours one by one, which may lead to some contour pixels being missed and not all contour pixels can be traced. For example, algorithms such as MNT and RSA cannot trace inner corner contour pixels. Although methods such as ISBF and FCTA achieve a high accuracy of 99.5%, their performance will drop sharply for complex or atypical contours. The calculation speed of traditional contour tracing techniques is slow and the memory occupancy is large. Traditional contour tracing techniques (SBF, MSBF, ISBF, MNT, RSA, TPA, and FCTA) need to process all pixels of the image, including redundant background pixels and object pixels. In addition, the per-contour tracing process, that is, entering the next contour tracing only after one contour tracing is completed, will disrupt the entire image scanning process when entering each contour tracing process, and each contour tracing process is a small loop, resulting in a slow calculation speed. To terminate a single contour tracing and return to the global scanning process, the starting point of each contour tracing needs to be recorded, and information such as the direction of entering each pixel also needs to be recorded during each contour tracing process, and these records consume a large amount of memory. Since there are overlaps between each contour tracing path and between each contour tracing path and the path of the entire image scanning, a large number of pixels will be traced repeatedly, resulting in waste of computing resources. Moreover, traditional contour tracing techniques cannot finely characterize the geometric features of contours and cannot diversely characterize the topological structure of contours. Since traditional contour tracing methods cannot capture all contour pixels, they cannot finely characterize the geometric features of contours. Traditional contour tracing methods only provide the position information of contour pixels for contour topological structure characterization and do not provide other information, and the information provided is limited, so they cannot diversely characterize the topological structure of contours. For example, all current contour tracing methods cannot determine the membership relationship between a contour and an entity object, that is, they do not know which entity object a certain contour belongs to. The per-contour tracing process is affected by factors such as the scanning direction, start condition, and stop criterion, and the results will vary with the changes of the above factors, and the algorithm stability is poor. Traditional contour tracing techniques adopt an integral design, with poor flexibility and unable to trace contours of different shapes specifically.
[0037] In view of this, some embodiments of the present application provide a contour tracing method. This method first identifies all potential contour pixels in the image and then assigns them to the corresponding contours, which ensures that all contour pixels are traced 100%. Moreover, in this method, the image is scanned from start to end according to a predefined scanning scheme, and the entire scanning process will not be interrupted by a single contour tracing process, ensuring the calculation rate and the stability of contour tracing.
[0038] The following combines the attached Figure 1 Exemplarily elaborates the implementation process of contour tracing executed by a terminal device provided by some embodiments of the present application.
[0039] Please refer to the appendix Figure 1 , Figure 1 which is a flowchart of a contour tracking method provided for some embodiments of the present application. The contour tracking method includes:
[0040] S110. Identify each pixel point in the image pixels to determine the pixel type and the current cluster number of each pixel point; wherein, the pixel types include: contour pixels, pseudo-contour pixels, background pixels, and internal entity pixels; each pixel point is characterized by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel point; the current cluster number is obtained by updating the initial cluster number.
[0041] For example, in some embodiments of the present application, first, all pixels in the image are represented using an initial three-dimensional pixel vector; then, the pixel vector is dimensionally increased, and an initial cluster number is introduced to obtain a four-dimensional pixel vector, that is, the pixel vector is P(i, j, g, 0), where i and j are the row number and column number of the pixel (as a specific example of the position information), 0 is the initial value of the cluster number (as a specific example of the initial cluster number), and g is the gray value (i.e., the pixel value). There may be multiple unrecognized contours in the image, and the image can be scanned in the order from top left to bottom right. By identifying each pixel point in the image, it is determined whether each pixel point belongs to a contour pixel, a pseudo-contour pixel, a background pixel, or an internal entity pixel, as well as the updated current cluster number.
[0042] In some embodiments of the present application, S110 may include:
[0043] S111. Determine the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point.
[0044] For example, in some embodiments of the present application, different from the traditional contour tracking algorithm that only relies on the pixel values of adjacent pixels to determine whether the current pixel is a contour pixel, in this embodiment, the pixel type is identified by using the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point during the scanning process. As Figure 2 shown, the middle gray square represents any pixel, the four dark gray pixels in its upper left corner are the upper Moore neighborhood pixel points of any pixel, and the four light gray pixels in its lower right corner are the lower Moore neighborhood pixel points of any pixel. In this way, all identified contour pixels and pseudo-contour pixels are placed in an overall contour segment set. The subsequent steps of the algorithm only process this set storing all contour segments, thereby filtering out background pixels and internal entity pixels and improving the computational efficiency of the algorithm. Figure 2 The arrows in
[0045] In some embodiments of the present application, S111 may include: if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel; if there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are two or more non-zero cluster numbers, then the any pixel point is a pseudo-contour pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point are all non-zero, then the any pixel point is an internal entity pixel; in the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point have zero values, then the any pixel point is a contour pixel, otherwise it is an internal entity pixel.
[0046] For example, in some embodiments of the present application, first analyze the upper Moore neighborhood pixel points of any pixel, and in the order of the arrows as Figure 2 shown, sequentially confirm the cluster numbers of the four red pixel points. If all four are zero cluster numbers, then the any pixel point is a contour pixel.
[0047] If there is a non-zero cluster number and there is one non-zero cluster number, it is a contour pixel. For example, there are three zero cluster numbers and one non-zero cluster number, or two zero cluster numbers and two identical non-zero cluster numbers; or one zero cluster number and three identical non-zero cluster numbers.
[0048] If there is a non-zero cluster number and there are two or more different types of non-zero cluster numbers, it is a pseudo-contour pixel. For example, there are two zero cluster numbers and two different non-zero cluster numbers; or there is one zero cluster number and three different non-zero cluster numbers; or, there is one zero cluster number and two different non-zero cluster numbers (where the non-zero cluster numbers of two pixel points are the same).
[0049] If there is no zero cluster number among the upper Moore neighborhood pixel points, at this time, it is necessary to analyze the pixel values of the lower Moore neighborhood pixel points. If the pixel values of the lower Moore neighborhood pixel points are all non-zero, then the pixel point of any pixel is an internal entity pixel, otherwise it is a contour pixel.
[0050] S112, take the first non-zero cluster number detected in order among the upper Moore neighborhood pixel points as the current cluster number of each pixel point.
[0051] For example, in some embodiments of the present application, in the process of sequentially analyzing the cluster numbers of the upper Moore neighborhood pixel points in the order as Figure 2 shown, take the cluster number of the pixel point with the first non-zero cluster number as the current cluster number of any pixel point, so as to update the cluster number of any pixel point. For example, the cluster number of the first detected non-zero cluster number in the red area is 3, and at this time, the current cluster number of the current pixel is 3.
[0052] In some embodiments of the present application, S112 may further include: when the upper Moore neighborhood pixel points all have a zero cluster number, adding one to the previously determined maximum cluster number as the current cluster number.
[0053] For example, in some embodiments of the present application, during the pixel type recognition process, the upper Moore neighborhood pixel points are analyzed first, and then the lower Moore neighborhood pixel points are analyzed. If the cluster numbers of the upper Moore neighborhood pixel points are all zero cluster numbers, at this time, the current cluster numbers of any pixel are encoded in sequence. The cluster numbers are encoded according to natural numbers. For example, after preliminary analysis, there are already 3 cluster numbers, which are 1, 2, and 3 respectively, and 3 is the previously determined maximum cluster number. At this time, the current cluster number of any pixel is 4. As Figure 3 shown, after pixel type recognition and determination of the current cluster number, the cluster number representation as shown in Figure 4 can be obtained (that is, Figure 4 the values of 1 to 5 in are the cluster numbers). The five boxed squares are pseudo contour pixels. Different gray levels represent different contour segments.
[0054] S120, generating a set storing all contour segments based on the pixel type and the current cluster number of each pixel point; the set storing all contour segments includes: contour segment sets of at least one object; each object's contour segment set in the contour segment sets of at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour segment; the second subset includes the cluster numbers of all adjacent contour segments of the contour segment.
[0055] For example, in some embodiments of the present application, an image may contain at least one object. After identifying the pixel types and current cluster numbers of all pixels, first generate a set storing all contour segments of the entire image; the set storing all contour segments contains contour segment sets of each object in at least one object, and the contour segment sets are further divided into two subsets, which respectively store the position information of all pixel points of the contour segments of the object and the cluster numbers of adjacent contour segments. Among them, the position information of all pixel points is stored in sequence, and the adjacent contour segments correspond to the order of the pixel points and are stored in sequence. It should be understood that when the second subset is a non-empty set, it indicates that there are pseudo contour pixels in the current contour segment. As Figure 4 shown, different gray levels represent different contour segments. Among them, the contour segment formed by the current cluster number 1 and the contour segment with the cluster number 2 are adjacent contour segments.
[0056] S130, merging the contour segments included in each object according to the contour segment set of each object to obtain a complete contour and the final cluster number of each pixel point in the complete contour.
[0057] For example, in some embodiments of the present application, the contour segments contained in each object are merged according to the set of contour segments of each object, pseudo contour pixels are cleared, and pairwise merging is adopted to finally obtain a complete contour and a final cluster number. Since the recognized contour segments contain pseudo contour pixels, by analyzing and merging the adjacent contour segments thereto, a complete contour and an updated final cluster number are obtained.
[0058] In some embodiments of the present application, S130 may include: performing the following operations in a loop until the complete contour is obtained: merging two adjacent contour segments containing the same pseudo contour pixel among adjacent contour segments according to a preset rule, clearing the pseudo contour pixel, and updating the maximum value in the cluster numbers of the pixel points contained in the adjacent contour segments to the cluster number of the contour pixel of the merged contour segment.
[0059] For example, in some embodiments of the present application, adjacent contour segments sharing the same pseudo contour pixel are iteratively merged through a union operator, and finally all pseudo contour pixels are eliminated to reconstruct a complete contour.
[0060] Specifically, a global integer array named SNC is created, where each element corresponds to the sequence number of all the determined contour segments (for example, the sequence number of the contour segment composed of cluster number 1 is 1), and the initial value of this array SNC is [1, 2,..., NBD]. Then a pointer variable Ncon is established, which initially points to the last element in the SNC array, that is, to the first contour segment in the contour segment merging process, and then the pointer Ncon moves forward in turn, continuously merging the contour segments in the above manner (that is, only merging two adjacent contour segments containing common pseudo contour pixels at a time) until all contour segments are merged and all pseudo contour pixels are deleted. It should be noted that when merging, in addition to starting from the last element, it can also start from other contour segments, and the embodiments of the present application are not limited thereto.
[0061] For example, taking Figure 4 the object to be recognized as an example, the SNC array is updated to [1, 2, 3, 4, 5]. Therefore, the Ncon pointer initially points to the last element 5. It can be seen that there are no pseudo contour pixels in this contour segment. Therefore, the Ncon continues to move forward and points to the fourth contour segment. As Figure 4 shown, the current contour segment contains three boxed pseudo contour pixels, indicating that it has three adjacent contour segments to be merged. The merging process proceeds in the following order.
[0062] First, the third contour segment is merged into the fourth contour segment because, according to the recognition order from top left to bottom right, the pseudo contour pixel between them is recognized earlier than the other two. As Figure 5As shown, the third contour segment has been merged into the fourth contour segment, and the SNC is updated to [1, 2, 4, 4, 5], where the third element changes from 3 to 4, which also represents that the cluster number of the pixel points in the third contour segment is updated to 4. As the pointer Ncon continues to move forward, the contour segments 5, 2, and 1 are successively merged into the contour segment 4 (see Figure 6 , Figure 7 and Figure 8 ). The SNC also gradually changes from [1, 2, 4, 4, 5] to [1, 2, 4, 4], then to [1, 4, 4, 4, 4], and finally to [4, 4, 4, 4, 4]. As Figure 9 shown, the complete contour with the serial number 4 (which is also the final cluster number) is formed, and all pseudo-contour pixels are cleared. The arrows in the figure indicate the just-cleared pseudo-contour pixels, and the black number 4 represents the final cluster number of the contour pixels to which the pixel is reallocated.
[0063] The following will exemplarily elaborate on the specific process of contour tracing provided by some embodiments of the present application in conjunction with the appended Figure 10 drawings.
[0064] Please refer to the appended Figure 10 , Figure 10 , which is a flowchart of the implementation of a contour tracing provided by some embodiments of the present application.
[0065] The following will exemplarily elaborate on the above process.
[0066] S210, add an initial cluster number to the initial pixel vector of the image pixels to obtain a pixel vector.
[0067] S220, analyze each pixel point in the image pixels by using the cluster numbers of the upper Moore neighborhood pixel points and the pixel values of the lower Moore neighborhood pixel points to obtain the pixel type and the current cluster number of each pixel point.
[0068] S230, generate a set storing all contour segments based on the pixel type of each pixel point and the current cluster number.
[0069] S240, according to a preset rule, merge the contour segments containing the same pseudo-contour pixel in the adjacent contour segments of each object in the set storing all contour segments, and update the cluster numbers of the pixel points contained in the adjacent contour segments to obtain a complete contour and a final cluster number.
[0070] It should be noted that the specific implementation processes of S210 to S240 can refer to the method embodiments provided above. To avoid repetition, the detailed descriptions are appropriately omitted here.
[0071] It can be seen from some of the above embodiments of the present application that the present application does not track contours one by one, but first identifies all potential contour pixels and then assigns them to the corresponding contour segments of each object. This innovation ensures 100% capture of contour pixels. The pixel vector dimensionality upgrading strategy proposed in the present application introduces new cluster number features through pixel vector dimensionality upgrading, enriches the amount of pixel information, and makes contour tracking more efficient and accurate.
[0072] Please refer to Figure 11 , Figure 11 The following is a block diagram of the contour tracking device provided by some embodiments of the present application. It should be understood that the contour tracking device corresponds to the above method embodiment and can perform each step involved in the above method embodiment. The specific functions of the contour tracking device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.
[0073] Figure 11 The contour tracing device includes at least one software function module that can be stored in a memory in the form of software or firmware or fixed in the contour tracing device, and the contour tracing device includes: an identification module 1110, used to identify each pixel point in the image pixel, and determine the pixel type and current cluster number of each pixel point; wherein the pixel type includes: contour pixel, pseudo contour pixel, background pixel and internal entity pixel; each pixel point is represented by a pixel vector, and the pixel vector includes: position information, pixel value and initial cluster number of each pixel point; the current cluster number is obtained after the initial cluster number is updated; a generation module 1120, used to generate a pixel vector based on the pixel vector; Based on the pixel type and the current cluster number of each pixel point, a set for storing all contour fragments is generated; the set for storing all contour fragments includes: a contour fragment set of at least one object; the contour fragment set of each object in the contour fragment set of at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour fragment; the second subset includes the cluster numbers of all adjacent contour fragments of the contour fragment; a merging module 1130 is used to merge the contour fragments contained in each object according to the contour fragment set of each object to obtain a complete contour and a final cluster number of each pixel point in the complete contour.
[0074] Technicians in the relevant field can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.
[0075] Some embodiments of the present application further provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the operations of the method corresponding to any of the above methods provided in the above embodiments.
[0076] Some embodiments of the present application also provide a computer program product, which includes a computer program. When the computer program is executed by a processor, it can implement the operations corresponding to any of the methods provided in the above-mentioned methods in the above embodiments.
[0077] As Figure 12 As shown, some embodiments of the present application provide an electronic device 1200, which includes: a memory 1210, a processor 1220, and a computer program stored on the memory 1210 and executable on the processor 1220. When the processor 1220 reads the program from the memory 1210 through a bus 1230 and executes the program, it can implement the method in any of the above embodiments.
[0078] The processor 1220 can process digital signals and can include various computing architectures. For example, a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements a combination of multiple instruction sets. In some examples, the processor 1220 can be a microprocessor.
[0079] The memory 1210 can be used to store instructions executed by the processor 1220 or data related to the execution of the instructions. These instructions and / or data can include code for implementing some or all of the functions of one or more modules described in the embodiments of the present application. The processor 1220 in the embodiments of the present disclosure can be used to execute the instructions in the memory 1210 to implement the method shown above. The memory 1210 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memories well known to those skilled in the art.
[0080] The above is only the embodiments of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0081] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or replacements, which should all be covered by the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
[0082] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent in such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
Claims
1. A method for contour tracking, characterized in that, Including: Identifying each pixel point in the image pixels to determine the pixel type and the current cluster number of each pixel point; wherein, the pixel type includes: contour pixels, pseudo-contour pixels, background pixels, and internal entity pixels; each pixel point is characterized by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel point; the current cluster number is obtained by updating the initial cluster number. Generating a set storing all contour segments based on the pixel type and the current cluster number of each pixel point; the set storing all contour segments includes: contour segment sets of at least one object; each object's contour segment set in the contour segment sets of at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour segment; the second subset includes the cluster numbers of all adjacent contour segments of the contour segment. Merging the contour segments included in each object according to the contour segment set of each object to obtain a complete contour and the final cluster number of each pixel point in the complete contour.
2. The method according to claim 1, wherein The identifying each pixel point in the image pixels to determine the pixel type and the current cluster number of each pixel point includes: Determining the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point. Taking the first non-zero cluster number detected in order among the upper Moore neighborhood pixel points as the current cluster number of each pixel point.
3. The method according to claim 2, wherein The determining the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point includes: If there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel. If there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are two or more non-zero cluster numbers, then the any pixel point is a pseudo-contour pixel. In the case that there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point are all non-zero, then the any pixel point is the internal entity pixel. In the case that there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel value of the lower Moore neighborhood pixel point of any pixel point has a zero value, then the any pixel point is a contour pixel, otherwise it is the internal entity pixel.
4. The method according to claim 3, wherein When all the upper Moore neighborhood pixel points are zero cluster numbers, adding one to the previously determined maximum cluster number as the current cluster number.
5. The method according to any one of claims 1 to 3, characterized in that, The merging the contour segments included in each object according to the contour segment set of each object to obtain a complete contour and the final cluster number of each pixel point in the complete contour includes: Repeatedly performing the following operations until the complete contour is obtained: Merging two adjacent contour segments containing the same pseudo-contour pixel among the adjacent contour segments according to a preset rule, clearing the pseudo-contour pixel, and updating the maximum value among the cluster numbers of the pixel points included in the adjacent contour segments to the cluster number of the contour pixel of the merged contour segment.
6. A contour tracking device, characterized in that, Including: An identification module for identifying each pixel point in the image pixels to determine the pixel type and the current cluster number of each pixel point; wherein, the pixel types include: contour pixels, pseudo-contour pixels, background pixels, and internal entity pixels; each pixel point is represented by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel point; the current cluster number is obtained by updating the initial cluster number. A generation module for generating a set storing all contour segments based on the pixel type and the current cluster number of each pixel point; the set storing all contour segments includes: contour segment sets of at least one object; each object's contour segment set in the contour segment sets of the at least one object includes a first subset and a second subset; the first subset includes the position information of all pixel points of the contour segment; the second subset includes the cluster numbers of all adjacent contour segments of the contour segment. A merging module for merging the contour segments contained in each object according to the contour segment set of each object to obtain a complete contour and the final cluster number of each pixel point in the complete contour.
7. The device according to claim 6, characterized in that, The identification module is used for: Determining the pixel type of each pixel point based on the cluster number of the upper Moore neighborhood pixel point and the pixel value of the lower Moore neighborhood pixel point of each pixel point. The Moore neighborhood pixel points include: upper Moore neighborhood pixel points and lower Moore neighborhood pixel points. Taking the first non-zero cluster number detected in sequence among the upper Moore neighborhood pixel points as the current cluster number of each pixel point.
8. The device according to claim 7, wherein The identification module is used for: If there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel. If there is a zero cluster number among the upper Moore neighborhood pixel points of any pixel point and there are two or more non-zero cluster numbers, then the any pixel point is a pseudo-contour pixel. In the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if the pixel values of the lower Moore neighborhood pixel points of any pixel point are all non-zero, then the any pixel point is the internal entity pixel. In the case where there is no zero cluster number among the upper Moore neighborhood pixel points, if there is a zero value in the pixel values of the lower Moore neighborhood pixel points of any pixel point, then the any pixel point is a contour pixel, otherwise it is the internal entity pixel.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, wherein the computer program, when run by a processor, executes the method according to any one of claims 1-5.
10. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and running on the processor, wherein the computer program, when run by the processor, executes the method according to any one of claims 1-5.
Citation Information
Patent Citations
Multi-class contour tracking method and device for multi-class images and medium
CN115861368A
Image external contour extraction method, device and medium
CN118247298A