A contour extraction method, device, equipment and storage medium

Through automatic threshold segmentation and reference data template processing, combined with grayscale and gradient adjustment, the adhesion pixel points are deleted, which solves the problem of unclear extraction of adjacent image contours and improves the cutting accuracy and effect.

CN114565627BActive Publication Date: 2025-07-22HANGZHOU IECHO SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210196889.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-01
Publication Date
2025-07-22
Estimated Expiration
2042-03-01

AI Technical Summary

Technical Problem

The prior art is difficult to effectively deal with the contour extraction problem of adjacent images being close to each other or locally adhesive, resulting in poor cutting accuracy and effect.

Method used

The binary image is obtained through automatic threshold segmentation, adjust the pixel value and combine it with the reference data template to perform grayscale and gradient processing, delete the contour pixel points that cause adhesion, update the contour information list, and finally generate a clear contour map.

Benefits of technology

Effective extraction of adjacent images close distances and local adhesion profiles is achieved, and the cutting accuracy and effect are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114565627B_ABST
    Figure CN114565627B_ABST
Patent Text Reader

Abstract

The present application discloses a contour extraction method, apparatus, device and storage medium. The method includes: obtaining an original image and performing automatic threshold segmentation to obtain a binary image; adjusting the pixel values at the non-0 pixel positions in the binary image to the pixel values of the corresponding pixel points in the original image to obtain a first image; adjusting the pixel values in the first image by using a reference data template to obtain a second image that includes both grayscale and gradient, and then performing image contour extraction to obtain a first contour map; determining a list containing contour information by using the contour pixel points in the first contour map, and updating the list by deleting the contour information of the contour pixel points that cause contour adhesion in the list according to a preset deletion condition; determining a second contour map according to the updated list. Through the technical solution of the present application, the extraction of contours with relatively close distances between adjacent images can be processed, and the extraction of locally adhered contours between adjacent images can be processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine vision, and particularly relates to a contour extraction method, device, equipment and storage medium. Background Art

[0002] Image contour extraction is an important step in intelligent cutting equipment, which directly affects the cutting accuracy and effect. At present, affected by noise, illumination, image acquisition equipment and material cost, etc., the target distances of images are relatively close or adhered to each other, and gray-scale segmentation is usually incomplete. For example, in textile material cutting, in order to save cloth as much as possible, the distance between patterns is less than 1 mm, resulting in a local adhesion phenomenon where two images are locally connected together (such as Figure 1 , Figure 2 ). In traditional contour extraction methods, based on the analysis of image content, computer technology is used to extract representative features in the image. For example, high thresholds are used to detect important lines and contours in the image. However, due to the pixel values between adjacent image contours being close or even equal, when the image distances are close, the image contours cannot be extracted by threshold segmentation, or the effect is not very ideal when using the gradient method for contour extraction. Therefore, no matter whether gray-scale threshold or gradient is used, the contours cannot be recognized, and the situation where the image distances are close and the respective complete contours cannot be extracted occurs. Only by increasing the image gap, such as the gap between two images being greater than 3 mm.

[0003] In summary, how to process the extraction of contours with close distances between adjacent images, and how to process the extraction of locally adhered contours between adjacent images are problems to be solved currently. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a contour extraction method, device, equipment and storage medium, which can process the extraction of contours with close distances between adjacent images and the extraction of locally adhered contours between adjacent images. The specific solutions are as follows:

[0005] In a first aspect, the present application discloses a contour extraction method, including:

[0006] Obtain an original image, and perform automatic threshold segmentation on the original image to obtain a binary image;

[0007] Adjust the pixel values at non-0 pixel positions in the binary image to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel position is a position where the pixel value corresponding to the pixel point in the binary image is not 0;

[0008] Adjust the pixel values in the first image using a reference data template to obtain a second image that contains both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map;

[0009] Use the contour pixel points in the first contour map to determine a list containing contour information, and use a preset deletion condition to delete the contour information of the contour pixel points that cause contour adhesion in the list to update the list;

[0010] Determine a second contour map according to the updated list.

[0011] Optionally, before adjusting the pixel values in the first image using the reference data template, it further includes:

[0012] Determine an image area for performing image gradient enhancement transformation on the first image based on a preset radius, and use the pixel values of the pixel points in the regional image corresponding to the image area on the first image as reference data to obtain the reference data template.

[0013] Optionally, adjusting the pixel values in the first image using the reference data template to obtain a second image that contains both grayscale and gradient includes:

[0014] Judge whether the pixel value of the pixel point in the reference data template is greater than a pixel threshold, where the pixel threshold is a threshold determined based on the preset radius;

[0015] If the pixel value of the pixel point in the reference data template is greater than the pixel threshold, adjust the pixel value of the corresponding pixel point in the first image to 0 to obtain a second image that contains both grayscale and gradient.

[0016] Optionally, after adjusting the pixel values in the first image using the reference data template to obtain a second image that contains both grayscale and gradient, it further includes:

[0017] Adjust the pixel values at non-0 pixel positions in the second image to 255, where the non-0 pixel positions are positions where the pixel values corresponding to the pixel points in the second image are not 0.

[0018] Optionally, determining a list containing contour information using the contour pixel points in the first contour map includes:

[0019] Establish a coordinate system based on the first contour map and determine the coordinate information of the contour pixel points in the coordinate system; the coordinate information includes the row coordinate and column coordinate of the contour pixel points;

[0020] Mark the corresponding serial numbers for the contour pixel points in the first contour map in sequence, and determine the coordinate information corresponding to different serial numbers;

[0021] Determine a list containing contour information based on the correspondence between the contour pixel points with the same row coordinates and different column coordinates in the coordinate information and the serial numbers;

[0022] Or, determine a list containing contour information based on the correspondence between the contour pixel points with the same column coordinates and different row coordinates in the coordinate information and the serial numbers.

[0023] Optionally, the step of using a preset deletion condition to delete the contour information of the contour pixel points causing contour adhesion in the list to update the list includes:

[0024] Determine the Euclidean distance between any two contour pixel points among all the contour pixel points and the difference in the corresponding serial numbers;

[0025] If the Euclidean distance is less than a first preset threshold and the difference is greater than a second preset threshold, then delete the corresponding contour pixel points to update the list.

[0026] Optionally, the step of determining a second contour map according to the updated list includes:

[0027] Perform drawing filling on the first contour map corresponding to the updated list and perform image contour extraction to obtain the second contour map.

[0028] In a second aspect, the present application discloses a contour extraction device, including:

[0029] An image acquisition module, configured to acquire an original image and perform automatic threshold segmentation on the original image to obtain a binary image;

[0030] A pixel adjustment module, configured to adjust the pixel values at the non-0 pixel positions in the binary image to the pixel values of the pixel points at the corresponding positions in the original image to obtain a first image; wherein, the non-0 pixel positions are the positions where the pixel values of the pixel points in the binary image are not 0;

[0031] A first contour extraction module, configured to adjust the pixel values in the first image by using a reference data template to obtain a second image containing both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map;

[0032] A list update module, configured to determine a list containing contour information by using the contour pixel points in the first contour map, and update the list by deleting the contour information of the contour pixel points causing contour adhesion in the list by using a preset deletion condition;

[0033] A second contour extraction module, configured to determine a second contour map according to the updated list.

[0034] In a third aspect, the present application discloses an electronic device, including:

[0035] A memory, configured to store a computer program;

[0036] A processor, configured to execute the computer program to implement the foregoing contour extraction method.

[0037] In a fourth aspect, the present application discloses a computer-readable storage medium, configured to store a computer program; wherein when the computer program is executed by a processor, the foregoing contour extraction method is implemented.

[0038] In the present application, a raw image is obtained, and the raw image is automatically threshold-segmented to obtain a binary image; the pixel values at non-0 pixel positions in the binary image are adjusted to the pixel values of the pixel points at the corresponding positions in the raw image to obtain a first image; wherein, the non-0 pixel positions are positions where the pixel values of the pixel points in the binary image are not 0; the pixel values in the first image are adjusted by using a reference data template to obtain a second image containing both grayscale and gradient, and then image contour extraction is performed on the second image to obtain a first contour map; a list containing contour information is determined by using the contour pixel points in the first contour map, and the contour information of the contour pixel points causing contour adhesion in the list is deleted by using a preset deletion condition to update the list; a second contour map is determined according to the updated list. It can be seen that, on the one hand, by reassigning the original image data to the binary image obtained by automatic threshold segmentation to obtain a first image, and then adjusting the pixel values of the pixel points in the first image by using a reference data template to obtain a second image containing both grayscale and gradient, and performing image contour extraction on the second image containing both grayscale and gradient, in this way, the extraction of contours with relatively close distances between adjacent images can be processed; on the other hand, a list containing contour information is determined by using the contour pixel points in the first contour map, and the contour pixel points causing contour adhesion in the list are deleted to update the list, and a second contour map is determined according to the updated list. By deleting the contour pixel points causing contour adhesion, the extraction of locally adhered contours of adjacent images can be processed. Description of the Drawings

[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.

[0040] Figure 1 Schematic diagram of a pattern edge being relatively close during contour extraction disclosed in this application;

[0041] Figure 2 Schematic diagram of pattern edge adhesion during contour extraction disclosed in this application;

[0042] Figure 3 Flowchart of a contour extraction method disclosed in this application;

[0043] Figure 4 Original image obtained during contour extraction disclosed in this application;

[0044] Figure 5 Binary image obtained during contour extraction disclosed in this application;

[0045] Figure 6 First image obtained during contour extraction disclosed in this application;

[0046] Figure 7 Second image obtained during contour extraction disclosed in this application;

[0047] Figure 8 Schematic diagram of the adjusted pixel values of the second image during a specific contour extraction disclosed in this application;

[0048] Figure 9 Schematic diagram of a specific contour disclosed in this application;

[0049] Figure 10 Schematic diagram of a specific corrected contour disclosed in this application

[0050] Figure 11 Schematic diagram of a specific contour extraction method disclosed in this application;

[0051] Figure 12 Flowchart of a specific contour extraction method disclosed in this application;

[0052] Figure 13 Schematic diagram of the list information generated during a specific contour extraction disclosed in this application;

[0053] Figure 14 Schematic diagram of the structure of a contour extraction device disclosed in this application;

[0054] Figure 15 This is a structural diagram of an electronic device disclosed in the present application. Detailed implementation manners

[0055] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0056] Currently, in traditional contour extraction methods, when the image distance is relatively close, the image contour cannot be extracted by threshold segmentation, or the effect is not very ideal when using the gradient method for contour extraction. Therefore, whether using grayscale threshold or gradient, the contour cannot be recognized, and the situation where the image distance is relatively close and the respective complete contours cannot be extracted occurs. Only by increasing the image gap can this problem be solved.

[0057] Therefore, the present application provides a contour extraction solution that can handle the extraction of contours with relatively close distances between adjacent images and the extraction of locally adhered contours between adjacent images.

[0058] An embodiment of the present invention discloses a contour extraction method. Refer to Figure 3 As shown, the method includes:

[0059] Step S11: Obtain an original image and perform automatic threshold segmentation on the original image to obtain a binary image.

[0060] In the embodiment of the present application, first, an original image is obtained, and then automatic threshold segmentation is performed on the original image to obtain a binary image. Exemplarily, as Figure 4 shown is the obtained original image, Figure 5 is the binary image obtained after performing automatic threshold segmentation on Figure 4 .

[0061] Step S12: Adjust the pixel values at the non-0 pixel positions in the binary image to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel position is the position where the pixel value of the pixel point in the binary image is not 0.

[0062] In the embodiment of the present application, the pixel values of the pixel points in the obtained binary image are re-assigned. Specifically: the pixel values at the non-0 pixel positions in the binary image are adjusted to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel position is the position where the pixel value of the pixel point in the binary image is not 0. As Figure 6The figure shows a first image obtained by reassigning the pixel values of the pixel points in a binary image.

[0063] Step S13: Adjust the pixel values in the first image using a reference data template to obtain a second image that includes both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map.

[0064] In the embodiment of the present application, a gradient enhancement transformation is performed on the first image based on a preset radius. For example, the Laplace operator is used for image enhancement, isotropic differentiation is performed, and edges are extracted to obtain an edge enhancement map. Here, the algorithm for performing the gradient enhancement transformation on the image is not specifically limited. Then, the data of this image is used as the reference template data. Specifically, an image area for performing the image gradient enhancement transformation on the first image is determined based on the preset radius, and the pixel values of the pixel points in the area image corresponding to the image area on the first image are used as the reference data to obtain the reference data template.

[0065] In the embodiment of the present application, after obtaining the reference data template, the pixel values in the first image are adjusted using a pixel threshold. It should be noted that the pixel threshold is a threshold determined based on the preset radius. Specifically, it is determined whether the pixel value of the pixel point in the reference data template is greater than the pixel threshold. If the pixel value of the pixel point in the reference data template is greater than the pixel threshold, the pixel value of the corresponding pixel point in the first image is adjusted to 0 to obtain a second image that includes both grayscale and gradient, and then image contour extraction is performed on the second image to obtain a first contour map. In this way, the extraction of contours with relatively close adjacent images can be processed.

[0066] In the embodiment of the present application, after obtaining the second image that includes both grayscale and gradient, it further includes: adjusting the pixel values at the non-0 pixel positions in the second image to 255, where the non-0 pixel positions are the positions where the pixel values corresponding to the pixel points in the second image are not 0.

[0067] As Figure 7 shown, it is the second image that includes both gradient and grayscale; as Figure 8 shown, it is the image obtained by reassigning Figure 7 the pixel values at the non-0 positions to 255. As Figure 9 shown, it is one of the contour maps obtained by performing image contour extraction on the second image.

[0068] Step S14: Determine a list containing contour information using the contour pixel points in the first contour map, and use a preset deletion condition to delete the contour information of the contour pixel points that cause contour adhesion in the list to update the list.

[0069] In the embodiments of the present application, after extracting the image contour of the second image to obtain the first contour map, a list containing contour information is determined using the contour pixel points in the first contour map. It can be understood that through the contour information, the image coordinate position where each contour pixel point is located and the serial number of the contour pixel point in the current contour sequence can be determined.

[0070] In the embodiments of the present application, the contour information of the contour pixel points causing contour adhesion in the list is deleted using a preset deletion condition to update the list. For example, the contour pixel points with relatively close image coordinate positions and relatively far serial numbers of the contour pixel points in the list are deleted. When the contour information of the contour pixel points causing contour adhesion is deleted, the image is corrected. In this way, the extraction of locally adhered contours of adjacent images can be processed.

[0071] Step S15: Determine the second contour map according to the updated list.

[0072] In the embodiments of the present application, after the contour information of the contour pixel points causing contour adhesion is deleted, the first contour map corresponding to the updated list is drawn and filled and image contour extraction is performed to obtain the second contour map. It can be understood that the second contour map is an image without local adhesion. Figure 10 Shown is one of the contour maps in the second contour map determined according to the updated list.

[0073] As Figure 11 shown, the overall process of the embodiments of the present application is as follows. First, the acquired image ( Figure 4 ) is read, and then an automatic threshold segmentation is performed to obtain a binary image ( Figure 5 ). Then, the pixel values at the non-0 pixel positions in the binary image are assigned the pixel values at the corresponding positions in the original image to obtain the first image, that is, the pixel values of the pixel points at the non-0 pixel positions in Figure 5 are adjusted to the pixel values at the corresponding positions in the original image, that is, Figure 4 to obtain Figure 6 ; then a gradient enhancement transformation is performed on the first image ( Figure 6 ) to obtain a reference data template, and then the pixel values of the pixel points in the first image ( Figure 6 ) are modified using the pixel values in the reference data template to generate a second image ( Figure 7 ) containing gradients and grayscales; the pixel values of the pixel points at the non-0 pixel positions in the second image ( Figure 7 ) are adjusted to 255 to obtain the adjusted image ( Figure 8 ); then contour extraction is performed on the adjusted image ( Figure 8 ) to generate a list containing contour information; among them, for Figure 8The image obtained after contour extraction may contain locally adhered contours. Further, the contour information of the contour pixel points that cause image adhesion in the list is deleted, that is, the contour pixel points with a far serial number and a close coordinate in the list are deleted. Finally, the contour is drawn and filled, and the contour is regenerated and output, and the entire process ends.

[0074] In this application, the original image is obtained, and the original image is automatically threshold-segmented to obtain a binary image; the pixel values at the non-0 pixel positions in the binary image are adjusted to be the same as the pixel values of the pixel points at the corresponding positions in the original image to obtain a first image; where the non-0 pixel position is the position where the pixel value corresponding to the pixel point in the binary image is not 0; the pixel values in the first image are adjusted using a reference data template to obtain a second image that contains both grayscale and gradient, and then the image contour of the second image is extracted to obtain a first contour map; the contour pixel points in the first contour map are used to determine a list containing contour information, and the contour information of the contour pixel points that cause contour adhesion in the list is deleted using a preset deletion condition to update the list; a second contour map is determined according to the updated list. It can be seen that, on the one hand, by reassigning the original image data to the binary image obtained by automatic threshold segmentation to obtain a first image, and then using a reference data template to adjust the pixel values of the pixel points in the first image to obtain a second image that contains both grayscale and gradient, and performing image contour extraction on the second image that contains both grayscale and gradient, in this way, the extraction of contours with a relatively close distance between adjacent images can be processed; on the other hand, the contour pixel points in the first contour map are used to determine a list containing contour information, and the contour pixel points that cause contour adhesion in the list are deleted to update the list, and a second contour map is determined according to the updated list. By deleting the contour pixel points that cause contour adhesion, the extraction of locally adhered contours of adjacent images can be processed.

[0075] An embodiment of this application discloses a specific contour extraction method. Refer to Figure 12 As shown, the method includes:

[0076] Step S21: Obtain the original image, and automatically threshold-segment the original image to obtain a binary image.

[0077] Step S22: Adjust the pixel values at the non-0 pixel positions in the binary image to be the same as the pixel values of the pixel points at the corresponding positions in the original image to obtain a first image; where the non-0 pixel position is the position where the pixel value corresponding to the pixel point in the binary image is not 0.

[0078] Step S23: Adjust the pixel values in the first image using the reference data template to obtain a second image that includes both grayscale and gradients, and then perform image contour extraction on the second image to obtain a first contour map.

[0079] Among them, for the more specific processing procedures of the above-mentioned Step S21, Step S22, and Step S23, reference can be made to the corresponding content disclosed in the foregoing embodiments, and details will not be elaborated here.

[0080] Step S24: Establish a coordinate system based on the first contour map and determine the coordinate information of the contour pixel points in the coordinate system.

[0081] In the embodiment of the present application, after obtaining the first contour map, a coordinate system can be established based on the first contour map. For example, a spatial coordinate system can be established with a corner of the first contour map as the coordinate origin. In this way, the coordinate information of the contour pixel points in the coordinate system can be obtained, where the coordinate information includes the row coordinates and column coordinates of the contour pixel points.

[0082] Step S25: Sequentially mark corresponding serial numbers for the contour pixel points in the first contour map, and determine the coordinate information corresponding to different serial numbers.

[0083] In the embodiment of the present application, along each contour in the first contour map, the contour pixel points are sequentially marked with corresponding serial numbers. It can be understood that each contour pixel point after being marked with a serial number corresponds to its own coordinate information. In this way, the image coordinate position where the contour pixel point is located can be determined through the serial number.

[0084] Step S26: Determine a list containing contour information based on the correspondence between the contour pixel points with the same row coordinates and different column coordinates in the coordinate information and the serial numbers; or, determine a list containing contour information based on the correspondence between the contour pixel points with the same column coordinates and different row coordinates in the coordinate information and the serial numbers.

[0085] In one implementation, a list containing contour information is determined based on the correspondence between the contour pixel points with the same row coordinates and different column coordinates in the coordinate information and the serial numbers. That is, by obtaining the same row coordinate value, different column coordinate values, and their respective corresponding serial numbers, a list containing the spatial coordinates of the contour pixel points and the serial numbers of the contour pixel points can be obtained.

[0086] In another embodiment, a list containing contour information is determined based on the correspondence between the contour pixel points with the same column coordinates and different row coordinates in the coordinate information. That is, by obtaining the same column coordinate value, different row coordinate values, and their respective serial numbers, a list containing the spatial coordinates of the contour pixel points and the serial numbers of the contour pixel points can be obtained.

[0087] As Figure 13 shown is a specific list diagram for obtaining the same row coordinate, i.e., the x coordinate, different column coordinates, i.e., the y coordinate, and the serial numbers of the contour pixel points corresponding to the coordinates.

[0088] Step S27: Use a preset deletion condition to delete the contour information of the contour pixel points in the list that cause contour adhesion, so as to update the list, and determine a second contour map according to the updated list.

[0089] In the embodiment of the present application, a preset deletion condition is used to delete the contour information of the contour pixel points in the list that cause contour adhesion, so as to update the list. Specifically, determine the Euclidean distance between any two contour pixel points among all the contour pixel points and the difference in the corresponding serial numbers; if the Euclidean distance is less than a first preset threshold and the difference is greater than a second preset threshold, then delete the corresponding contour pixel points to update the list.

[0090] It can be seen that on the one hand, by reassigning the original image data to the binary image obtained by automatic threshold segmentation to obtain a first image, and then using a reference data template to adjust the pixel values of the pixel points in the first image to obtain a second image that contains both grayscale and gradient, and then performing image contour extraction on the second image that contains both grayscale and gradient. In this way, the extraction of contours with relatively close distances between adjacent images can be processed; on the other hand, a list containing contour information is determined using the contour pixel points in the first contour map, and the contour pixel points in the list that cause contour adhesion are deleted to update the list, and a second contour map is determined according to the updated list. By deleting the contour pixel points that cause contour adhesion, the extraction of locally adhered contours between adjacent images can be processed.

[0091] Correspondingly, the embodiment of the present application also discloses a contour extraction device. Refer to Figure 14 shown, the device includes:

[0092] An image acquisition module 11, configured to acquire an original image and perform automatic threshold segmentation on the original image to obtain a binary image;

[0093] The pixel adjustment module 12 is configured to adjust the pixel values at the non-0 pixel positions in the binary image to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel positions are the positions where the pixel values corresponding to the pixel points in the binary image are not 0;

[0094] The first contour extraction module 13 is configured to adjust the pixel values in the first image by using a reference data template to obtain a second image that includes both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map;

[0095] The list update module 14 is configured to determine a list containing contour information by using the contour pixel points in the first contour map, and use a preset deletion condition to delete the contour information of the contour pixel points that cause contour adhesion in the list to update the list;

[0096] The second contour extraction module 15 is configured to determine a second contour map according to the updated list.

[0097] Wherein, for the more specific working processes of the above-mentioned respective modules, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not described herein again.

[0098] It can be seen that through the above solution of this embodiment, the original image is obtained, and the original image is automatically threshold-segmented to obtain a binary image; the pixel values at the non-0 pixel positions in the binary image are adjusted to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel positions are the positions where the pixel values corresponding to the pixel points in the binary image are not 0; the pixel values in the first image are adjusted using a reference data template to obtain a second image that contains both grayscale and gradient, and then the image contour of the second image is extracted to obtain a first contour map; the contour pixel points in the first contour map are used to determine a list containing contour information, and the contour information of the contour pixel points that cause contour adhesion in the list is deleted using a preset deletion condition to update the list; a second contour map is determined according to the updated list. It can be seen that, on the one hand, by reassigning the original image data to the binary image obtained by automatic threshold segmentation to obtain a first image, and then using a reference data template to adjust the pixel values of the pixel points in the first image to obtain a second image that contains both grayscale and gradient, and then extracting the image contour of the second image that contains both grayscale and gradient, in this way, the extraction of contours with a relatively close distance between adjacent images can be processed; on the other hand, the contour pixel points in the first contour map are used to determine a list containing contour information, and the contour pixel points that cause contour adhesion in the list are deleted to update the list, and a second contour map is determined according to the updated list. By deleting the contour information of the contour pixel points that cause contour adhesion, the extraction of locally adhered contours between adjacent images can be processed.

[0099] Furthermore, an embodiment of the present application also discloses an electronic device, Figure 15 which is a structural diagram of an electronic device 20 shown according to an exemplary embodiment. The content in the figure should not be regarded as any limitation on the scope of use of the present application.

[0100] Figure 15 This is a schematic structural diagram of an electronic device 20 provided by an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the contour extraction method disclosed in any of the foregoing embodiments.

[0101] In this embodiment, the power supply 23 is used to provide operating voltages for the various hardware devices on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and no specific limitation is imposed on it here; the input / output interface 25 is used to obtain external input data or output data to the outside, and the specific interface type can be selected according to specific application requirements, and no specific limitation is imposed here.

[0102] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon can include an operating system 221, a computer program 222, and data 223, etc. The data 223 can include various kinds of data. The storage method can be temporary storage or permanent storage.

[0103] Among them, the operating system 221 is used to manage and control the various hardware devices and the computer program 222 on the electronic device 20, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the contour extraction method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.

[0104] Furthermore, the embodiment of this application also discloses a computer-readable storage medium. The computer-readable storage medium mentioned here includes a random access memory (RAM), an internal memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk, or an optical disc, or any other form of storage medium well-known in the technical field. Among them, when the computer program is executed by a processor, the foregoing contour extraction method is implemented. For the specific steps of this method, reference can be made to the corresponding content disclosed in the foregoing embodiments, and details are not described here again.

[0105] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and reference can be made to the description of the method part for related parts.

[0106] The steps of the contour extraction or algorithm described in combination with the embodiments disclosed in this article can be implemented directly in hardware, software modules executed by a processor, or a combination of both. The software module can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.

[0107] Finally, it should also 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 such actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is 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 also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0108] The above has introduced in detail a contour extraction method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A contour extraction method, characterized in that, Including: Obtain an original image, and perform automatic threshold segmentation on the original image to obtain a binary image; Adjust the pixel values at non-0 pixel positions in the binary image to the pixel values of the corresponding pixel points in the original image to obtain a first image; wherein, the non-0 pixel positions are the positions where the pixel values of the pixel points in the binary image are not 0; Adjust the pixel values in the first image using a reference data template to obtain a second image that includes both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map; Determine a list containing contour information using the contour pixel points in the first contour map, and delete the contour information of the contour pixel points that cause contour adhesion in the list using a preset deletion condition to update the list; Determine a second contour map according to the updated list; Wherein, before adjusting the pixel values in the first image using the reference data template, it further includes: Determine an image region for performing image gradient enhancement transformation on the first image based on a preset radius, and use the pixel values of the pixel points in the region image corresponding to the image region on the first image as reference data to obtain the reference data template; Wherein, adjusting the pixel values in the first image using the reference data template to obtain a second image that includes both grayscale and gradient includes: Judge whether the pixel value of the pixel point in the reference data template is greater than a pixel threshold, wherein the pixel threshold is a threshold determined based on the preset radius; If the pixel value of the pixel point in the reference data template is greater than the pixel threshold, then adjust the pixel value of the corresponding pixel point in the first image to 0 to obtain a second image that includes both grayscale and gradient.

2. The contour extraction method according to claim 1, wherein After adjusting the pixel values in the first image using the reference data template to obtain a second image that includes both grayscale and gradient, it further includes: Adjust the pixel values at non-0 pixel positions in the second image to 255, wherein the non-0 pixel positions are the positions where the pixel values of the pixel points in the second image are not 0.

3. The contour extraction method according to claim 1, characterized in that, Determining a list containing contour information using the contour pixel points in the first contour map includes: Establish a coordinate system based on the first contour map, and determine the coordinate information of the contour pixel points in the coordinate system; the coordinate information includes the row coordinate and column coordinate of the contour pixel points; Mark corresponding serial numbers for the contour pixel points in the first contour map in sequence, and determine the coordinate information corresponding to different serial numbers; Determine a list containing contour information based on the correspondence between the contour pixel points with the same row coordinate and different column coordinates in the coordinate information and the serial numbers; Or, determine a list containing contour information based on the correspondence between the contour pixel points with the same column coordinate and different row coordinates in the coordinate information and the serial numbers.

4. The contour extraction method according to claim 3, characterized in that, Deleting the contour information of the contour pixel points that cause contour adhesion in the list using a preset deletion condition to update the list includes: Determine the Euclidean distance between any two of the contour pixel points among all the contour pixel points and the difference in the corresponding serial numbers; If the Euclidean distance is less than a first preset threshold and the difference is greater than a second preset threshold, then delete the corresponding contour pixel point to update the list.

5. The contour extraction method according to any one of claims 1 to 4, characterized in that The determining the second contour map according to the updated list includes: Perform drawing filling on the first contour map corresponding to the updated list and perform image contour extraction to obtain the second contour map.

6. A contour extraction device, characterized in that, It includes: An image acquisition module, configured to acquire an original image and perform automatic threshold segmentation on the original image to obtain a binary image; A pixel adjustment module, configured to adjust the pixel values at the non-0 pixel positions in the binary image to the pixel values of the pixel points at the corresponding positions in the original image to obtain a first image; wherein, the non-0 pixel positions are the positions where the pixel values of the pixel points in the binary image are not 0; A first contour extraction module, configured to adjust the pixel values in the first image by using a reference data template to obtain a second image that includes both grayscale and gradient, and then perform image contour extraction on the second image to obtain a first contour map; A list update module, configured to determine a list including contour information by using the contour pixel points in the first contour map, and use a preset deletion condition to delete the contour information of the contour pixel points that cause contour adhesion in the list to update the list; A second contour extraction module, configured to determine a second contour map according to the updated list; Wherein, the contour extraction device is further configured to: Determine an image area for performing image gradient enhancement transformation on the first image based on a preset radius, and use the pixel values of the pixel points in the area image corresponding to the image area on the first image as reference data to obtain the reference data template; Wherein, the first contour extraction module is configured to: Judge whether the pixel value of a pixel point in the reference data template is greater than a pixel threshold, wherein the pixel threshold is a threshold determined based on the preset radius; If the pixel value of a pixel point in the reference data template is greater than the pixel threshold, then adjust the pixel value of the corresponding pixel point in the first image to 0 to obtain a second image that includes both grayscale and gradient.

7. An electronic device, characterized in that, It includes: A memory, configured to store a computer program; A processor, configured to execute the computer program to implement the contour extraction method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, For storing a computer program; wherein the computer program, when executed by the processor, implements the contour extraction method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Image enhancement and noise reduction method and system based on Laplacian operator

    CN113034376A

  • Object detection device

    JP2010204752A