Contour tracking method and device, storage medium and electronic equipment
By identifying and merging outline fragments of image pixel points, the problems of low efficiency and poor accuracy of traditional outline tracking technology are solved, and efficient and stable outline tracking is achieved.
Patent Information
- Application Number
- CN202510571915.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2045-05-06
AI Technical Summary
Traditional contour tracking technology has low efficiency and difficult to guarantee accuracy. It cannot effectively track internal angle contour pixels, slow calculation speed and poor stability.
By identifying the pixel points of the image, determining the pixel type and the current cluster number, generating a set of all contour fragments, and combining them according to the cluster numbers of adjacent contour fragments to obtain the complete contour and final cluster number.
It realizes accurate identification and tracking of object outlines, improves the efficiency and stability of outline tracking, and ensures 100% contour pixel capture.
Smart Images

Figure CN120088291A_ABST
Abstract
Description
Technical Field
[0001] The present 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 the present application aim to provide a method, device, storage medium and electronic device for contour tracking. Through the technical solutions of the embodiments of the present 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 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; based on the pixel type and the current cluster number of each pixel point, generating a set storing all contour segments; 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 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 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 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 there is a zero value among 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 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 execute the following operations until the complete contour is obtained: According to a preset rule, merge two adjacent contour segments among the adjacent contour segments that contain the same pseudo contour pixel, clear the pseudo contour pixel, and update the cluster number of the contour pixel of the merged contour segment to the maximum value among the cluster numbers of the pixel points contained in the adjacent contour segments.
[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 a contour tracking device, 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 points and the pixel value of the lower Moore neighborhood pixel points 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 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 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. When the processor executes the program, the method described in any embodiment 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, and when the computer program is executed by a processor, the method described in any embodiment 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 therefore should not be regarded as a limitation of the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0022] Figure 1 One of the method flowcharts of contour tracking provided by some embodiments of the present application; Figure 2 Schematic diagram of pixel distribution provided by some embodiments of the present application; Figure 3 Schematic diagram of the contour of a complex connected region provided by some embodiments of the present application; Figure 4 One of the schematic diagrams of contour segment merging provided by some embodiments of the present application; Figure 5 Two of the schematic diagrams of contour segment merging provided by some embodiments of the present application; Figure 6 Three of the schematic diagrams of contour segment merging provided by some embodiments of the present application; Figure 7 Four of the schematic diagrams of contour segment merging provided by some embodiments of the present application; Figure 8 Five of the schematic diagrams of contour segment merging provided by some embodiments of the present application; Figure 9 Schematic diagram of the complete contour provided by some embodiments of the present application; Figure 10 Two of the method flowcharts of contour tracking provided by some embodiments of the present application; Figure 11 Block diagram of the composition of the contour tracking device provided by some embodiments of the present application; Figure 12 Schematic diagram of an electronic device provided by some embodiments of the present application. Detailed implementation manners
[0023] The following will describe the technical solutions in some embodiments of the present application with reference to the accompanying drawings in some embodiments of the present application.
[0024] 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, terms such as "first" and "second" are only used for differential description and cannot be understood as indicating or implying relative importance.
[0025] Traditional methods adopt a strategy of tracing each contour one by one, which may cause some contour pixels to be 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, their process of tracing each contour one by one, 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, it is also necessary to record the starting point of each contour tracing, and information such as the direction of entering each pixel needs to be recorded during each contour tracing process. These records all 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 the contour and cannot diversely characterize the topological structure of the contour. Since traditional contour tracing methods cannot capture all contour pixels, they cannot finely characterize the geometric features of the contour. Traditional contour tracing methods only provide the position information of contour pixels for the characterization of the contour topological structure and do not provide other information. The information provided is limited, and thus the topological structure of the contour cannot be diversely characterized. For example, none of the current contour tracing methods can determine the membership relationship between the contour and the entity object, that is, it is not known which entity object a certain contour belongs to. The process of tracing each contour one by one 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 overall design, with poor flexibility and unable to trace contours of different shapes targeted.
[0026] In view of this, some embodiments of the present application provide a contour tracing method. This method first identifies all potential contour pixels in an image and then assigns them to corresponding contours, ensuring that all contour pixels are traced 100%. Moreover, in this method, the image is scanned from beginning 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.
[0027] 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.
[0028] Please refer to the attached Figure 1 , Figure 1 which is a flowchart of a contour tracing method provided by some embodiments of the present application. The contour tracing method includes: 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 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.
[0029] 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 grayscale 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.
[0030] In some embodiments of the present application, S110 may include: 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.
[0031] For example, in some embodiments of the present application, different from the traditional contour tracing 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 2As shown, the middle gray square represents any pixel. The four dark gray pixels in the upper left corner of it are the upper Moore neighborhood pixel points of any pixel, and the four light gray pixels in the lower right corner of it are the lower Moore neighborhood pixel points of any pixel. In this way, all the identified contour pixels and pseudo-contour pixels are put into an overall contour segment set. The subsequent steps of this algorithm only process the set storing all the contour segments, thereby filtering out the background pixels and internal entity pixels and improving the computational efficiency of the algorithm. Figure 2 The arrow in Figure 2 indicates the order when confirming the cluster numbers of the upper Moore neighborhood pixel points and the pixel values of the lower Moore neighborhood pixel points.
[0032] 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 the 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 the internal entity pixel.
[0033] 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 arrow as shown in Figure 2 confirm the cluster numbers of the four red pixel points in sequence. If all four are zero cluster numbers, then the any pixel point is a contour pixel.
[0034] 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.
[0035] If there is a non-zero cluster number and there are two or more different 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).
[0036] 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 the any pixel is an internal entity pixel, otherwise it is a contour pixel.
[0037] S112. 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.
[0038] For example, in some embodiments of the present application, during the process of analyzing the cluster numbers of the upper Moore neighborhood pixel points in sequence as shown Figure 2 in the order shown, use 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 detected as non-zero for the first time in the red area is 3, and at this time, the current cluster number of the current pixel is 3.
[0039] In some embodiments of the present application, S112 may further include: 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.
[0040] For example, in some embodiments of the present application, during the pixel type recognition process, first analyze the upper Moore neighborhood pixel points, and then analyze the lower Moore neighborhood pixel points. 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 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 colors represent different contour segments.
[0041] S120. 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 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.
[0042] 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, a set storing all contour segments of the entire image is first generated; 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 sequentially, and the adjacent contour segments correspond to the order of the pixel points and are stored sequentially. 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.
[0043] S130. Merge 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.
[0044] For example, in some embodiments of the present application, the contour segments contained in each object are merged according to the contour segment set 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.
[0045] In some embodiments of the present application, S130 may include: 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 in the adjacent contour segments, clear the pseudo-contour pixel, and update 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.
[0046] 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.
[0047] Specifically, create a global integer array named SNC, where each element corresponds to the serial number of all the contour segments determined above (for example, the serial number of the contour segment composed of cluster number 1 is 1). The initial value of this array SNC is [1, 2, …, NBD]. Then establish a pointer variable Ncon, which initially points to the last element in the SNC array, that is, points to the first contour segment in the contour segment merging process. Then the pointer Ncon moves forward in turn, and continuously merges the contour segments in the above manner (that is, only merge two adjacent contour segments containing common pseudo-contour pixels at a time) until all the contour segments are merged and all the 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. The embodiments of the present application are not limited to this.
[0048] For example, taking Figure 4 the object to be recognized in 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, 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.
[0049] First, merge the third contour segment into the fourth contour segment because, according to the recognition order from top left to bottom right, the pseudo-contour pixels between them are recognized earlier than the other two. As Figure 5 shown, the third contour segment has been merged into the fourth contour segment, and at the same time 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 ). 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, a complete contour with a serial number of 4 (which is also the final cluster number) is formed, and at the same time all the 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.
[0050] The following specifically describes the contour tracking process provided by some embodiments of the present application with reference to the attached Figure 10 drawings.
[0051] Please refer to the attached Figure 10 , Figure 10 which is a flowchart of the implementation of contour tracking provided for some embodiments of the present application.
[0052] The above process will be described exemplarily below.
[0053] S210, Add an initial cluster number to the initial pixel vector of the image pixel to obtain a pixel vector.
[0054] S220, Analyze each pixel point in the image pixel 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.
[0055] S230, Generate a set storing all contour segments based on the pixel type of each pixel point and the current cluster number.
[0056] 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.
[0057] 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 description is appropriately omitted here.
[0058] As can be seen from some embodiments of the present application above, in the present application, instead of tracking the contours one by one, all potential contour pixels are first identified and then assigned to the corresponding contour segments of each object. This innovation ensures 100% capture of contour pixels; the pixel vector dimension elevation strategy proposed in the present application, through pixel vector dimension elevation, introduces new cluster number features, enriches the information volume of pixels, and makes contour tracking more efficient and accurate.
[0059] Please refer to Figure 11 , Figure 11 which shows a block diagram of the composition of the contour tracking device provided for some embodiments of the present application. It should be understood that this contour tracking device corresponds to the above method embodiments and can execute each step involved in the above method embodiments. The specific functions of this contour tracking device can be seen in the description above. To avoid repetition, the detailed description is appropriately omitted here.
[0060] Figure 11The 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.
[0061] 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.
[0062] 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.
[0063] Some embodiments of the present application further provide a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operations corresponding to any of the above methods provided in the above embodiments.
[0064] like 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 in the memory 1210 and executable on the processor 1220, wherein the processor 1220 can implement a method as described in any of the above embodiments when reading the program from the memory 1210 through a bus 1230 and executing the program.
[0065] 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.
[0066] 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 of the embodiments of the present disclosure can be used to execute the instructions in the memory 1210 to implement the methods 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.
[0067] The above are only the embodiments of the present application and are 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 modifications, equivalent replacements, improvements, 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 denote similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0068] As mentioned above, this 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 should be subject to the protection scope of the claims.
[0069] It should be noted that in this document, 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 term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.
Claims
1. A contour tracing method, characterized in that: include: Identify each pixel in the image pixels, and determine the pixel type and current cluster number of each pixel; wherein the pixel types include: contour pixels, pseudo contour pixels, background pixels, and internal entity pixels; each pixel is represented by a pixel vector, and the pixel vector includes: the position information, pixel value, and initial cluster number of each pixel; the current cluster number is obtained after the initial cluster number is updated; Based on the pixel type of each pixel point and the current cluster number, a set storing all contour fragments is generated; the set 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 position information of all pixel points of the contour fragment; the second subset includes cluster numbers of all adjacent contour fragments of the contour fragment; The contour segments contained in each object are merged according to the contour segment set of each object to obtain a complete contour and a final cluster number of each pixel point in the complete contour.
2. The method according to claim 1, characterized in that The step of identifying each pixel in the image and determining the pixel type and current cluster number of each pixel includes: Determining the pixel type of each pixel based on the cluster number of the upper moorish neighborhood pixel points and the pixel value of the lower moorish neighborhood pixel points of each pixel point; The first non-zero cluster number detected in sequence in the upper Moore neighborhood pixel points is used as the current cluster number of each pixel point.
3. The method according to claim 2, characterized in that The step of determining the pixel type of each pixel based on the cluster number of the upper Moore neighborhood pixel points of each pixel point and the pixel value of the lower Moore neighborhood pixel point comprises: If any pixel point has a zero cluster number among the upper Moore neighborhood pixel points, and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel; If any pixel point has a zero cluster number among the upper Moore neighborhood pixel points, and contains 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 in 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; When there is no zero cluster number in 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, characterized in that When all the pixels in the upper Moore neighborhood have a cluster number of zero, the previously determined maximum cluster number is incremented by one to serve as the current cluster number.
5. The method according to any one of claims 1 to 3, characterized in that The step of merging the contour segments contained in each object according to the contour segment set of each object to obtain a complete contour and a final cluster number of each pixel point in the complete contour includes: The following operations are performed cyclically until the complete contour is obtained: According to preset rules, two adjacent contour segments containing the same pseudo contour pixel are merged, the pseudo contour pixel is removed, and the maximum value among the cluster numbers of the pixel points contained in the adjacent contour segments is updated as the cluster number of the contour pixels of the merged contour segment.
6. A contour tracking device, characterized in that: include: The identification module is used to identify each pixel in the image pixels and determine the pixel type and current cluster number of each pixel; wherein the pixel types include: contour pixels, pseudo contour pixels, background pixels and internal entity pixels; each pixel is represented by a pixel vector, and the pixel vector includes: the position information, pixel value and initial cluster number of each pixel; the current cluster number is obtained after the initial cluster number is updated; A generating module, configured to generate a set storing all contour fragments based on the pixel type of each pixel point and the current cluster number; the set 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 position information of all pixel points of the contour fragment; the second subset includes cluster numbers of all adjacent contour fragments of the contour fragment; The merging module 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.
7. The device according to claim 6, characterized in that The identification module is used to: Determining the pixel type of each pixel based on the cluster number of the upper moorish neighborhood pixel points and the pixel value of the lower moorish neighborhood pixel points of each pixel point; The molar neighborhood pixel points include: upper molar neighborhood pixel points and lower molar neighborhood pixel points; The first non-zero cluster number detected in sequence in the upper Moore neighborhood pixel points is used as the current cluster number of each pixel point.
8. The device according to claim 7, characterized in that The identification module is used to: If any pixel point has a zero cluster number among the upper Moore neighborhood pixel points, and there are less than two non-zero cluster numbers, then the any pixel point is a contour pixel; If any pixel point has a zero cluster number among the upper Moore neighborhood pixel points, and contains 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 in 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; When there is no zero cluster number in 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.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program executes the method according to any one of claims 1 to 5 when executed by a processor.
10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the computer program executes the method according to any one of claims 1 to 5 when being run by the processor.
Citation Information
Patent Citations
Fingerprint image completion simulation method and system
CN107145839A
Method and device for eliminating false contour in image, and storage medium
CN114494026A
Multi-class contour tracking method and device for multi-class images and medium
CN115861368A
Image external contour extraction method, device and medium
CN118247298A
Method, device, and computer program for detecting boundary of object in image
US20230306609A1