Image contour extraction method and device, electronic equipment and storage medium
By acquiring images in the feeding direction of the cutting machine and performing contour extraction and splicing, the problem of pattern contour truncation in the continuous processing of ultra-long materials is solved, and accurate identification and cross-frame splicing of incomplete patterns are achieved, improving the accuracy of pattern contour extraction and cutting precision.
Patent Information
- Application Number
- CN202511259341.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-04
- Publication Date
- 2025-11-18
AI Technical Summary
In the continuous processing of ultra-long materials, existing technologies cannot automatically identify and compensate for the pattern contours that are segmented due to the limitations of the cutting area, resulting in missing contour data and incorrect cutting trajectories in the final output.
By acquiring images along the feeding direction of the cutting machine, contour extraction and splicing processing are performed, including background inversion filling, morphological operations and preset condition filtering, to identify complete and incomplete pattern contours. Incomplete pattern areas are accurately cropped and spliced with subsequent images to build a closed-loop contour integrity guarantee mechanism.
It ensures the integrity of pattern contours in continuous images, significantly improves the accuracy and cutting precision of extracting periodic or continuous pattern contours on ultra-long materials, and avoids contour truncation problems caused by limited cutting range.
Smart Images

Figure CN120976248A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to an image contour extraction method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] In the continuous processing of ultra-long materials, image contour extraction technology typically processes images on a per-image basis, failing to automatically identify and compensate for patterns segmented by the cutting area in preceding and following images. Consequently, when the cutting machine scans segment by segment along the feeding direction, the pattern contours at the edges of the material are often truncated, leading to missing contour data and incorrect cutting trajectories in the final output.
[0003] Therefore, how to maintain the integrity of the truncated pattern outline under continuous feeding conditions is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide an image contour extraction method, apparatus, electronic device, and computer-readable storage medium, which effectively solves the problem of contour truncation caused by the limitation of the cropping range in continuous images and significantly improves the accuracy of extracting the contours of periodic or continuous patterns on ultra-long materials.
[0005] To achieve the above objectives, this application provides an image contour extraction method, comprising:
[0006] Acquire the first original image along the feeding direction of the cutting machine;
[0007] Contour extraction is performed on the first original image to obtain a contour-filled image;
[0008] In the contour-filled image, determine the complete pattern contour and the incomplete pattern contour, and output the complete pattern contour;
[0009] Based on the height range of all the incomplete pattern contours, the corresponding positions of the images to be stitched are extracted from the first original image;
[0010] A second original image is obtained after the first original image along the feeding direction of the cutting machine. The image to be stitched is stitched with the second original image to form a third original image. The third original image is then used as the first original image again, and the process of extracting the contour of the first original image to obtain a contour-filled image is repeated, so as to achieve the extraction of the contour of the continuous image.
[0011] The process of extracting contours from the first original image to obtain a contour-filled image includes:
[0012] The background in the first original image is filled with the inverse color of the edge line color of the first original image to obtain the first intermediate image;
[0013] The first intermediate image is binarized to obtain a binarized image; wherein the background of the binarized image is black and the foreground is white;
[0014] A second intermediate image is obtained by adding a white horizontal line with a preset number of pixels wide to the bottom of the binarized image;
[0015] Based on the preset quantity, the operation parameters of the morphological opening operation are determined, and the morphological opening operation is performed on the second intermediate image based on the operation parameters to obtain the image to be extracted, so as to convert the non-closed pattern in the second intermediate image into a closed pattern.
[0016] Contour extraction is performed on the image to be extracted to obtain a contour-filled image.
[0017] The process of adding a white horizontal line with a preset number of pixels wide to the bottom of the binarized image to obtain a second intermediate image further includes:
[0018] Contour extraction is performed on the second intermediate image, and the extracted contours are filtered based on preset conditions to generate an intermediate contour-filled image.
[0019] Accordingly, based on the operational parameters, a morphological opening operation is performed on the second intermediate image to obtain the image to be extracted, so as to convert the non-closed pattern in the second intermediate image into a closed pattern, including:
[0020] Based on the operational parameters, a morphological opening operation is performed on the intermediate contour-filled image to obtain the image to be extracted, so as to convert the non-closed contours in the intermediate contour-filled image into closed contours.
[0021] Accordingly, contour extraction is performed on the image to be extracted to obtain a contour-filled image, including:
[0022] The image to be extracted is subjected to contour extraction, and the extracted contours are filtered based on preset conditions to generate a contour-filled image.
[0023] Specifically, determining complete and incomplete pattern contours in the contour-filled image and outputting the complete pattern contour includes:
[0024] The contour data in the contour-filled image is saved to a contour set;
[0025] Iterate through each contour in the contour set and determine whether the contour is a complete pattern contour.
[0026] If so, the outline is saved to the complete pattern outline set, and the complete pattern outline in the complete pattern outline set is output.
[0027] If not, the outline is saved to the incomplete outline set.
[0028] Determining whether the contour is a complete pattern contour includes:
[0029] Determine the height of the first original image, and calculate the height difference between the height of the first original image and the height of the preset number of pixels;
[0030] The height range between the height difference and the height of the first original pattern is defined as the incomplete contour height range.
[0031] Determine whether there are contour points in the contour whose height values fall within the height range of the incomplete contour;
[0032] If so, the outline is determined to be an incomplete pattern outline;
[0033] If not, then the outline is determined to be a complete pattern outline.
[0034] The process of extracting the corresponding position of the image to be stitched from the first original image based on the height range of all the incomplete pattern contours includes:
[0035] Determine the bounding rectangle of all contour points in the incomplete pattern contour set, and determine the height range of the bounding rectangle;
[0036] Based on the height range of the circumscribed rectangle, the corresponding position of the image to be stitched is extracted from the first original image.
[0037] Wherein, the height of the first original image is less than or equal to the length of the cutting range of the cutting machine along the feeding direction;
[0038] The height of the second original image is less than or equal to the difference between the length of the cutting range of the cutting machine along the feeding direction and the height of the circumscribed rectangle.
[0039] To achieve the above objectives, this application provides an image contour extraction apparatus, comprising:
[0040] The acquisition module is used to acquire a first original image along the feeding direction of the cutting machine.
[0041] The contour extraction module is used to extract contours from the first original image to obtain a contour-filled image.
[0042] A determination module is used to determine complete pattern contours and incomplete pattern contours in the contour-filled image, and output the complete pattern contours;
[0043] The cropping module is used to crop the image to be stitched in the first original image at the corresponding position based on the height range of all the incomplete pattern contours;
[0044] The stitching module is used to acquire a second original image after the first original image along the feeding direction of the cutting machine, stitch the image to be stitched together with the second original image to form a third original image, use the third original image as the first original image again, and restart the workflow of the contour extraction module to achieve the extraction of continuous image contours.
[0045] To achieve the above objectives, this application provides an electronic device, comprising:
[0046] Memory, used to store computer programs;
[0047] A processor is configured to implement the steps of the image contour extraction method described above when executing the computer program.
[0048] To achieve the above objectives, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the image contour extraction method described above.
[0049] The image contour extraction method provided in this application constructs a closed-loop contour integrity guarantee mechanism by dynamically stitching and iteratively processing continuous images acquired along the feeding direction of a cutting machine. This method not only achieves real-time recognition and output of complete patterns in a single frame image, but more importantly, it breaks through the limitation of related technologies being restricted to a single frame's field of view by accurately truncating incomplete pattern regions and stitching them with subsequently acquired images to form new processing inputs. This method of extending incomplete contour information from the previous frame to the next frame for fusion processing enables the system to continuously track and completely restore continuous pattern contours spanning multiple frames, effectively solving the contour truncation problem caused by the limited cutting range in continuous images, and significantly improving the accuracy of extracting periodic or continuous pattern contours on ultra-long materials. This application also discloses an image contour extraction device, an electronic device, and a computer-readable storage medium, which can achieve the same technical effects.
[0050] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. The drawings are used to provide a further understanding of this disclosure and constitute a part of the specification. They are used together with the following detailed description to explain this disclosure, but do not constitute a limitation of this disclosure. In the drawings:
[0052] Figure 1 This is a flowchart illustrating an image contour extraction method according to an exemplary embodiment;
[0053] Figure 2 A flowchart illustrating another image contour extraction method according to an exemplary embodiment;
[0054] Figure 3 This is a schematic diagram illustrating a first original image according to an exemplary embodiment;
[0055] Figure 4 This is a schematic diagram illustrating a first intermediate image according to an exemplary embodiment;
[0056] Figure 5 This is a schematic diagram illustrating a binarized image according to an exemplary embodiment;
[0057] Figure 6 An exemplary embodiment is shown below. Figure 5 A magnified view of a portion of the image;
[0058] Figure 7 This is a schematic diagram illustrating a second intermediate image according to an exemplary embodiment;
[0059] Figure 8 An exemplary embodiment is shown below. Figure 7 A magnified view of a portion of the image;
[0060] Figure 9 This is a schematic diagram illustrating an intermediate contour filling map according to an exemplary embodiment;
[0061] Figure 10 An exemplary embodiment is shown below. Figure 9 Enlarged view of a portion;
[0062] Figure 11 This is a schematic diagram illustrating an image to be extracted according to an exemplary embodiment;
[0063] Figure 12 An exemplary embodiment is shown below. Figure 11 Enlarged view of a portion;
[0064] Figure 13 This is a schematic diagram illustrating a contour-filled image according to an exemplary embodiment;
[0065] Figure 14 This is a schematic diagram illustrating an image to be stitched together according to an exemplary embodiment;
[0066] Figure 15 This is a schematic diagram illustrating a second original image according to an exemplary embodiment;
[0067] Figure 16 This is a schematic diagram illustrating a third original image according to an exemplary embodiment;
[0068] Figure 17 An exemplary embodiment is shown below. Figure 16 The corresponding outline diagram;
[0069] Figure 18 This is a structural diagram of an image contour extraction apparatus according to an exemplary embodiment;
[0070] Figure 19 This is a structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0071] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. Furthermore, in the embodiments of this application, "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0072] This application discloses an image contour extraction method, which is applicable to scenarios where a cutting machine performs segmented image acquisition and automatic cutting of ultra-long materials with continuous patterns, ensuring the integrity of the pattern contour.
[0073] See Figure 1 A flowchart illustrating an image contour extraction method according to an exemplary embodiment is shown below. Figure 1 As shown, it includes:
[0074] S101: Acquire the first original image along the feeding direction of the cutting machine;
[0075] In this step, during the operation of the cutting machine, as the material to be processed moves continuously along the feeding direction, an image acquisition device (such as an industrial camera) installed at a fixed position acquires a frame image of the surface of the material, which is the first original image. This image acquisition process is synchronized with the movement of the material to ensure that the acquired image accurately reflects the actual pattern distribution of the material within the current cutting area. Since the cutting area of the cutting machine is limited, only a local area of the material can be acquired at a time; therefore, the first original image may contain the truncated outline of part of the pattern.
[0076] As one possible implementation, the height of the first original image is less than or equal to the length of the cutting range of the cutting machine along the feeding direction.
[0077] In this embodiment, the height of the first original image acquired by the image acquisition module in the feeding direction is set to not exceed the length of the single-cut area of the cutting machine in the feeding direction. In specific implementations, the camera's field of view or image capture area is adjusted according to the cutting platform size of the cutting machine and the material movement speed to ensure that the height of the acquired first original image matches or is slightly smaller than the cutting range. For example, if the length of the single-cut area of the cutting machine along the feeding direction is 30 cm, the height of the first original image is set to not exceed 30 cm, and can be slightly smaller than this value to reserve overlapping areas for splicing. By ensuring that the height of the first original image matches the cutting capacity of the cutting machine, the problem of pattern loss caused by the image coverage exceeding the actual operable cutting range can be avoided.
[0078] S102: Extract the contour from the first original image to obtain a contour-filled image;
[0079] In this step, the first original image undergoes preprocessing operations such as denoising and binarization to enhance image contrast and reduce interference. Subsequently, an edge detection algorithm (such as the Canny algorithm) is used to extract all contour information in the image, and broken contours are connected using morphological closing operations to form a continuous contour structure. Finally, the detected contour regions are filled to generate a contour-filled image. This contour-filled image not only preserves the geometry of the original pattern but also enhances the continuity and integrity of the contours.
[0080] As a feasible implementation, contour extraction of the first original image to obtain a contour-filled image includes: filling the background of the first original image with the inverse color of the edge line color of the first original image to obtain a first intermediate image; performing binarization processing on the first intermediate image to obtain a binarized image; wherein the background of the binarized image is black and the foreground is white; adding a white horizontal line with a width of a preset number of pixels to the bottom of the binarized image to obtain a second intermediate image; determining the operation parameters of morphological opening operation based on the preset number, performing morphological opening operation on the second intermediate image based on the operation parameters to obtain an image to be extracted, so as to convert the non-closed pattern in the second intermediate image into a closed pattern; and performing contour extraction on the image to be extracted to obtain a contour-filled image.
[0081] In the specific implementation, firstly, the dominant color tone of the edge region of the first original image is analyzed, and the background region of the image is filled with its inverse color to generate a first intermediate image, thereby enhancing the contrast between the foreground pattern and the background. Then, this image is binarized to form a standard binarized image with a black background and a white foreground. Next, a white horizontal line with a width of a preset number of pixels (pixelWidth) is added to the bottom of this binarized image (i.e., along the rear edge of the feeding direction), forming a second intermediate image. The pixelWidth can be set to a range of 5-10. This white line is used to simulate pattern connection areas that may continue from the next frame. Then, the morphological opening operation parameters are set according to the preset number of pixels. For example, the kernel of the morphological opening operation can be set to (5, 2×pixelWidth-1). The opening operation is performed on the second intermediate image to smooth edges, connect broken lines, and close partially open patterns, thereby transforming the originally discontinuous or open patterns into visually closed structures, obtaining the image to be extracted. Finally, contour extraction is performed on this image to obtain a contour-filled image with stronger closure.
[0082] As can be seen, the above implementation significantly improves the integrity of edge breakage or opening patterns through background inversion filling, bottom white line guidance and morphological closure processing, effectively prevents contour misjudgment caused by image truncation, and provides high-quality input images for subsequent complete contour recognition and stitching.
[0083] As a feasible implementation, after adding a white horizontal line with a preset number of pixels wide to the bottom of the binarized image to obtain a second intermediate image, the method further includes: extracting contours from the second intermediate image and filtering the extracted contours based on preset conditions to generate an intermediate contour-filled image; correspondingly, performing a morphological opening operation on the second intermediate image based on the operation parameters to obtain an image to be extracted, so as to convert the non-closed patterns in the second intermediate image into closed patterns, including: performing a morphological opening operation on the intermediate contour-filled image based on the operation parameters to obtain an image to be extracted, so as to convert the non-closed contours in the intermediate contour-filled image into closed contours; correspondingly, extracting contours from the image to be extracted to obtain a contour-filled image, including: extracting contours from the image to be extracted and filtering the extracted contours based on preset conditions to generate a contour-filled image.
[0084] In practice, after generating the second intermediate image, a preliminary contour extraction is performed. The extracted contours are then filtered based on preset conditions such as width, height, area, and convexity to generate an intermediate contour-filled image. This image retains only the effective foreground area, removing most noise and invalid structures. Subsequently, based on morphological operation parameters determined by a preset number of pixels, morphological opening operations are performed on the intermediate contour-filled image, focusing on connecting and closing the non-closed parts of the effective contours to generate the image to be extracted. Finally, contour extraction is performed again on this image, and the same preset conditions are applied for secondary filtering to output the final contour-filled image.
[0085] As can be seen, the above implementation method avoids the amplification effect of morphological operations on noise through the dual optimization strategy of "filtering first, closing then filtering again", which significantly improves the robustness and accuracy of contour processing. It not only preserves the structural integrity of the real pattern, but also effectively suppresses the generation of pseudo contours caused by background interference or image noise. It is particularly suitable for image processing scenarios with complex textures or low-contrast materials, and further ensures the reliability of subsequent complete pattern recognition and cross-frame stitching.
[0086] S103: Determine the complete pattern contour and the incomplete pattern contour in the contour-filled image, and output the complete pattern contour;
[0087] In this step, the integrity of a contour is determined based on its spatial position within the image. The image is filled with contours, and the geometric features of each contour and its positional relationship on the image boundary are analyzed. If a contour is completely inside the image and closed, it is determined to be a "complete pattern contour"; if a contour intersects with the bottom edge of the image or is partially missing, it is determined to be an "incomplete pattern contour". Complete pattern contours are directly output for subsequent cropping control; incomplete pattern contours are retained and not output or cropped.
[0088] In practice, a judgment region can be set near the bottom of the image (e.g., within a few pixels from the bottom). All contours in the contour-filled image are traversed. If a contour has coordinates that fall within this bottom judgment region, it is determined to be an incomplete pattern contour; otherwise, it is determined to be a complete pattern contour.
[0089] As can be seen, this step enables automatic identification of the integrity of the pattern outline in the image, ensuring that the cutting operation is performed only on complete patterns, avoiding product defects caused by erroneous cutting, and improving cutting accuracy and yield.
[0090] As a feasible implementation method, determining complete and incomplete pattern contours in the contour-filled image and outputting the complete pattern contour includes: saving the contour data in the contour-filled image to a contour set; sequentially traversing each contour in the contour set and determining whether the contour is a complete pattern contour; if so, saving the contour to the complete pattern contour set and outputting the complete pattern contour in the complete pattern contour set; if not, saving the contour to the incomplete pattern contour set.
[0091] In practice, all contour data in the contour-filled image is first saved to a contour set. Then, each contour in this set is traversed, and each contour is identified as a complete pattern contour based on specific criteria. If a contour is deemed complete, it is added to the complete pattern contour set, and all complete pattern contours in this set are ultimately output; conversely, if a contour is considered incomplete, it is categorized into the incomplete contour set.
[0092] As a feasible implementation method, determining whether the contour is a complete pattern contour includes: determining the height of the first original image; calculating the height difference between the height of the first original image and the height of the preset number of pixels; determining the height range of the incomplete contour from the height range between the height difference and the height of the first original image; determining whether there are contour points in the contour whose height values are within the height range of the incomplete contour; if yes, then the contour is determined to be an incomplete pattern contour; if no, then the contour is determined to be a complete pattern contour.
[0093] In this embodiment, the integrity of a contour is determined by comparing its height information. Specifically, the height of the first original image is first determined, and the height difference between it and a previously set preset number of pixels (typically used to add a white horizontal line at the bottom) is calculated. Then, based on this height difference and the height range of the first original image, a height range within which an incomplete contour might exist is defined. Next, for each contour, it is checked whether any point within it falls within the defined height range of an incomplete contour. If so, the contour is considered an incomplete pattern contour; otherwise, it is considered a complete pattern contour. This process helps to accurately distinguish between complete and incomplete pattern contours.
[0094] S104: Based on the height range of all the incomplete pattern contours, extract the corresponding position of the image to be stitched from the first original image;
[0095] In this step, for each identified incomplete pattern outline, its distribution range in the height direction (i.e., the feeding direction of the cutting machine) within the image is analyzed. Based on the overall height range of all incomplete pattern outlines, the corresponding position in the first original image is cropped to obtain the image to be stitched. This image retains the original pixel information, especially including the continuation of the pattern at the image edges, providing crucial data for subsequent image stitching.
[0096] As a possible implementation method, the image to be stitched is cropped from the first original image at the corresponding position based on the height range of all the incomplete pattern contours, including: determining the bounding rectangle of all contour points in the incomplete pattern contour set, and determining the height range of the bounding rectangle; and cropping the image to be stitched from the first original image at the corresponding position based on the height range of the bounding rectangle.
[0097] In practice, for all contour points contained in all contours of the incomplete pattern contour set, their bounding rectangles are calculated, and the height range of these bounding rectangles is determined. Subsequently, based on the height range of these bounding rectangles, a precise image cropping operation is performed on the first original image to obtain the image segments to be stitched together.
[0098] S105: Obtain the second original image after the first original image along the feeding direction of the cutting machine, stitch the image to be stitched together with the second original image to form a third original image, use the third original image as the first original image again, and re-enter step S102 to achieve continuous image contour extraction.
[0099] In this step, the cutting machine continues feeding, and the image acquisition device acquires the next frame image, i.e., the second original image. The image to be stitched generated in step S104 is spatially aligned and fused with this second original image. Seamless stitching is achieved using image registration techniques (such as feature point matching or pixel intensity overlap alignment), generating an extended third original image. This image includes the unfinished pattern continuation from the previous frame and the new content of the current frame. Subsequently, the third original image is input as a new first original image to step S102 for re-extraction and analysis of the contour. This closed-loop process enables continuous tracking and stitching of continuous patterns across frames, achieving complete contour extraction of long strips or periodic patterns.
[0100] As one possible implementation, the height of the second original image is less than or equal to the difference between the length of the cutting range of the cutting machine along the feeding direction and the height of the circumscribed rectangle.
[0101] Understandably, when considering stitching multiple image segments together to form a larger pattern, it is essential to ensure that the size of each input image segment (i.e., the second original image) is suitable for the cutting machine's working capacity, while reserving sufficient space to compensate for incomplete pattern portions represented by the circumscribed rectangle. Therefore, the height of the third original image needs to be less than or equal to the length of the cutting machine's cutting range along the feeding direction. The height of the third original image is the sum of the heights of the image to be stitched and the second original image. The height of the image to be stitched is the height of the circumscribed rectangle. Thus, the height of the second original image needs to be less than or equal to the difference between the length of the cutting machine's cutting range along the feeding direction and the height of the circumscribed rectangle.
[0102] The image contour extraction method provided in this application constructs a closed-loop contour integrity guarantee mechanism by dynamically stitching and iteratively processing continuous images acquired along the feeding direction of the cutting machine. This method not only achieves real-time recognition and output of complete patterns in a single frame image, but more importantly, it breaks through the limitations of related technologies that are restricted to a single frame's field of view by accurately truncating incomplete pattern regions and stitching them with subsequently acquired images to form new processing inputs. This method of extending incomplete contour information from the previous frame to the next frame for fusion processing enables the system to continuously track and completely restore continuous pattern contours spanning multiple frames, effectively solving the contour truncation problem caused by the limited cutting range in continuous images, and significantly improving the accuracy of extracting periodic or continuous pattern contours on ultra-long materials.
[0103] This application discloses an image contour extraction method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0104] See Figure 2A flowchart illustrating another image contour extraction method according to an exemplary embodiment, such as... Figure 2 As shown, it includes:
[0105] S201: Acquire a first original image along the feeding direction of the cutting machine; wherein the height of the first original image is less than or equal to the length of the cutting range of the cutting machine along the feeding direction;
[0106] In this step, a first raw image of the surface of the material to be processed is acquired using an image acquisition device, such as... Figure 3 As shown, the white foreground represents the material, and the dark background represents the felt, ensuring that its height does not exceed the maximum length that the cutting machine can process in a single pass. This step guarantees that each processed image is within the device's capabilities, avoiding the problem of images being too large to be processed correctly.
[0107] S202: Fill the background in the first original image with the inverse color of the edge line color of the first original image to obtain the first intermediate image;
[0108] In this step, to improve the speed and accuracy of subsequent image contour recognition, the background is filled with a color opposite to the pattern edge color; for example, if the edge is dark, the background is filled with white. Figure 4 As shown, the reverse is also true. This helps to highlight the contrast between the foreground and background, making the contours more distinct and simplifying the subsequent binarization process. This operation improves image processing efficiency and enhances the accuracy of contour detection.
[0109] S203: The first intermediate image is binarized to obtain a binarized image; wherein the background of the binarized image is black and the foreground is white;
[0110] In this step, image segmentation is performed on the first intermediate image to obtain a binarized image with a black background and a white foreground, as shown below. Figure 5 As shown.
[0111] S204: Add a white horizontal line with a width of a preset number of pixels to the bottom of the binarized image to obtain a second intermediate image;
[0112] In this step, because Figure 5 The pattern (sample) immediately below the bottom of the image is incomplete and not closed; a magnified view of the part is shown below. Figure 6 As shown, to ensure that the incomplete pattern in the current version can be correctly extracted and easily stitched with the next version image, a horizontal line with a width of pixelWidth, where 𝑝𝑖𝑥𝑒l𝑊𝑖d𝑡ℎ ranges from 5 to 10, and has a grayscale value of 255 needs to be added to the bottom of the image to obtain the second intermediate image, as shown. Figure 7 As shown. By Figure 7 As you can see, an additional white line has been added to the bottom of the image, and the pattern that was previously open at the bottom has become closed after the line was added. (The text then abruptly shifts to a seemingly unrelated topic: cropping near the bottom of the image.) Figure 7 A close-up view at the bottom, such as... Figure 8 As shown, the pattern immediately below the bottom of the image is a closed pattern. This step ensures that the pattern outline at the bottom of the image is closed, making it easier to correctly identify and process these incomplete patterns during subsequent outline extraction, thereby achieving accurate image stitching.
[0113] S205: Extract contours from the second intermediate image and filter the extracted contours based on preset conditions to generate an intermediate contour-filled image;
[0114] In this step, contour extraction is performed on the second intermediate image, and the contour width, height, area, and convexity are used for filtering. This coarse extraction generates an intermediate contour-filled image, as shown below. Figure 9 As shown. This step aims to remove unnecessary noisy contours, retaining only those contours that truly represent the pattern features, effectively improving the accuracy of contour extraction and reducing the workload of subsequent processing.
[0115] S206: Determine the operation parameters of the morphological opening operation based on the preset quantity, and perform the morphological opening operation on the intermediate contour-filled image based on the operation parameters to obtain the image to be extracted, so as to convert the non-closed contours in the intermediate contour-filled image into closed contours.
[0116] Because the straight line added at the bottom of the image still exists. Figure 9 In, such as Figure 10 As shown, to further refine the contour extraction, the straight lines at the bottom of the image need to be removed. In this step, a morphological opening operation with a kernel of (5, 2×pixelWidth-1) can be performed to remove the added straight lines and other irrelevant lines at the bottom of the image, resulting in the image to be extracted, as shown. Figure 11 As shown, by Figure 11 It can be seen that the added straight line at the bottom of the image has been removed, and the pattern immediately following the bottom of the image is a closed pattern. (The last sentence appears to be incomplete and possibly refers to cropping near the bottom of the image.) Figure 11 A close-up view at the bottom, such as... Figure 12 As shown, the bottom straight line has been removed, and the pattern is now closed. This step improves the closure of the image outline, enhancing the quality of the final image stitching.
[0117] S207: Extract contours from the image to be extracted, and filter the extracted contours based on preset conditions to generate a contour-filled image;
[0118] In this step, the image to be extracted is subjected to contour search, and the contour is refined by filtering with contour width, height, area, and convexity to generate a contour-filled image.
[0119] S208: Save the contour data in the second contour-filled image to the contour set;
[0120] In this step, the contour data of each sample is saved to the contoursFinal collection (contour collection).
[0121] S209: Iterate through each contour in the contour set in sequence and determine whether there are contour points in the contour whose height values are within the height range of the incomplete contour; wherein, the height range of the incomplete contour is the height range between the height difference between the height of the first original image and the height of the preset number of pixels and the height of the first original pattern; if yes, proceed to S211; if no, proceed to S210.
[0122] S210: Save the outline to a complete pattern outline set, and output the complete pattern outline in the complete pattern outline set;
[0123] S211: Save the contour to an incomplete pattern contour set, determine the bounding rectangle of all contour points in the incomplete pattern contour set, and determine the height range of the bounding rectangle;
[0124] S212: Based on the height range of the circumscribed rectangle, extract the corresponding position of the image to be stitched from the first original image;
[0125] In specific implementation, the integrity of the pattern contour is determined as follows: The image height `imgHeight` is obtained. All contours in `contoursFinal` are traversed. If the Y-value of a point within a contour lies between `imgHeight - pixelWidth` and `imgHeight` near the bottom of the image, then the contour is an incomplete pattern contour and is saved to the `undoneContours` set (the set of incomplete pattern contours). Otherwise, the contour is a complete pattern contour and is saved to the `doneContours` set (the set of complete pattern contours). The contours in `doneContours` and `undoneContours` are then compared in the first original image (…). Figure 3 The effect shown on the screen is as follows: Figure 13 The green outline represents the complete pattern outline, which is output and cut, while the red outline represents the incomplete pattern outline, which is retained and not cut for the time being.
[0126] Furthermore, for all points in the incomplete image contour set unoneContours, calculate the horizontal bounding rectangle Rect, and then in the first original image ( Figure 3 Extract the image within the Rect range from the given image to obtain the image to be stitched together, such as... Figure 14 As shown.
[0127] S213: Acquire a second original image after the first original image along the feeding direction of the cutting machine; wherein the height of the second original image is less than or equal to the difference between the length of the cutting range of the cutting machine along the feeding direction and the height of the circumscribed rectangle;
[0128] Because the cutting range of the cutting machine is fixed and limited, to ensure that the unfinished sample from the previous version can be completely cut in the next version, the feeding length of the next version needs to be recalculated. The cutting range of the cutting machine along the feeding direction is Lc (mm), and the height of the circumscribed rectangle Rect, converted from pixels to millimeters, is Hu (mm). Therefore, the feeding length of the next version is: Ls = Lc - Hu. Feed Ls (mm) along the feeding direction, capture and read the second original image, such as... Figure 15 As shown.
[0129] S214: The image to be stitched is stitched together with the second original image to form a third original image. The third original image is then used as the first original image again, and the process re-enters step S202 to achieve the extraction of continuous image contours.
[0130] In this step, the image to be stitched is stitched together with the second original image to form the third original image, as follows: Figure 16 As shown, the third original image is used again as the first original image, and the process re-enters step S202 to extract the stitched contour, as follows. Figure 17 As shown, by repeatedly executing the above process, the integrity of continuous image samples in ultra-long materials can be extracted and cut.
[0131] Therefore, this embodiment enhances edge contrast and forces the closure of cross-frame contours by performing background inversion filling, adding bottom guide lines, and morphological closure processing on the original image, significantly improving the recognizability and continuity of incomplete patterns. Based on a preset pixel range, the integrity of the contour is dynamically judged, and the area to be stitched is precisely extracted, avoiding information loss and redundant processing. By stitching the image blocks corresponding to the incomplete contours with subsequent frames and iteratively processing them, seamless connection of contour information between multiple frames is achieved. This method not only ensures the timely output and cropping of complete patterns but also guarantees the final integrity of cross-frame patterns through adaptive feeding control, improving the automation, continuity, and cropping accuracy of image contour extraction. It is suitable for efficient and high-yield processing of long strip or periodic patterns.
[0132] The following describes an image contour extraction device provided in an embodiment of this application. The image contour extraction device described below and the image contour extraction method described above can be referred to each other.
[0133] See Figure 18A structural diagram of an image contour extraction apparatus according to an exemplary embodiment is shown, such as... Figure 18 As shown, it includes:
[0134] The acquisition module 100 is used to acquire a first original image along the feeding direction of the cutting machine.
[0135] The contour extraction module 200 is used to extract contours from the first original image to obtain a contour-filled image.
[0136] The determination module 300 is used to determine the complete pattern contour and the incomplete pattern contour in the contour filling image, and output the complete pattern contour;
[0137] The cropping module 400 is used to crop the image to be stitched in the first original image at the corresponding position based on the height range of all the incomplete pattern contours.
[0138] The splicing module 500 is used to acquire a second original image after the first original image along the feeding direction of the cutting machine, splice the image to be spliced with the second original image to form a third original image, use the third original image as the first original image again, and restart the workflow of the contour extraction module to achieve the extraction of continuous image contours.
[0139] The image contour extraction device provided in this application constructs a closed-loop contour integrity guarantee mechanism by dynamically stitching and iteratively processing continuous images acquired along the feeding direction of the cutting machine. This method not only achieves real-time recognition and output of complete patterns in a single frame image, but more importantly, it breaks through the limitations of related technologies that are restricted to a single frame's field of view by accurately cropping incomplete pattern regions and stitching them with subsequently acquired images to form new processing inputs. This method of extending incomplete contour information from the previous frame to the next frame for fusion processing enables the system to continuously track and completely restore continuous pattern contours spanning multiple frames, effectively solving the problem of contour truncation caused by the limited cutting range in continuous images, and significantly improving the accuracy of extracting periodic or continuous pattern contours on ultra-long materials.
[0140] Based on the above embodiments, as a preferred embodiment, the contour extraction module 200 includes:
[0141] A fill unit is used to fill the background in the first original image with the inverse color of the edge line color of the first original image to obtain a first intermediate image;
[0142] A binarization unit is used to perform binarization processing on the first intermediate image to obtain a binarized image; wherein the background of the binarized image is black and the foreground is white;
[0143] An adding unit is used to add a white horizontal line with a width of a preset number of pixels to the bottom of the binarized image to obtain a second intermediate image;
[0144] The operation unit is used to determine the operation parameters of the morphological opening operation based on the preset quantity, and to perform the morphological opening operation on the second intermediate image based on the operation parameters to obtain the image to be extracted, so as to convert the non-closed pattern in the second intermediate image into a closed pattern.
[0145] The second extraction unit is used to extract the contour of the image to be extracted to obtain a contour-filled image.
[0146] Based on the above embodiments, as a preferred embodiment, the contour extraction module 200 further includes:
[0147] The first extraction unit is used to add a white horizontal line with a width of a preset number of pixels to the bottom of the binarized image to obtain a second intermediate image, then extract the contour of the second intermediate image, and filter the extracted contour based on preset conditions to generate an intermediate contour-filled image.
[0148] Accordingly, the computing unit is specifically used to: perform morphological opening operation on the intermediate contour-filled image based on the computing parameters to obtain the image to be extracted, so as to convert the non-closed contours in the intermediate contour-filled image into closed contours;
[0149] Accordingly, the second extraction unit is specifically used to: extract contours from the image to be extracted, and filter the extracted contours based on preset conditions to generate a contour-filled image.
[0150] Based on the above embodiments, as a preferred implementation, the determining module 300 includes:
[0151] The first storage unit is used to save the contour data in the contour-filled image to the contour set;
[0152] The judgment unit is used to sequentially traverse each contour in the contour set and determine whether the contour is a complete pattern contour; if yes, the workflow of the second saving unit is started; if no, the workflow of the third saving unit is started.
[0153] The second storage unit is used to save the outline to a complete pattern outline set and output the complete pattern outline in the complete pattern outline set.
[0154] The third storage unit is used to save the outline to an incomplete outline set.
[0155] Based on the above embodiments, as a preferred implementation, the determining unit is specifically used to: determine the height of the first original image; calculate the height difference between the height of the first original image and the height of the preset number of pixels; determine the height range of the incomplete contour between the height difference and the height of the first original pattern; determine whether there are contour points in the contour whose height values are within the height range of the incomplete contour; if so, determine that the contour is an incomplete pattern contour; if not, determine that the contour is a complete pattern contour.
[0156] Based on the above embodiments, as a preferred implementation, the cropping module 400 is specifically used to: determine the circumscribed rectangle of all contour points in the incomplete pattern contour set, and determine the height range of the circumscribed rectangle; and crop the image to be stitched at the corresponding position in the first original image based on the height range of the circumscribed rectangle.
[0157] Based on the above embodiments, as a preferred embodiment, the height of the first original image is less than or equal to the length of the cutting range of the cutting machine along the feeding direction; the height of the second original image is less than or equal to the difference between the length of the cutting range of the cutting machine along the feeding direction and the height of the circumscribed rectangle.
[0158] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0159] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 19 This is a structural diagram of an electronic device according to an exemplary embodiment, such as... Figure 19 As shown, the electronic device includes:
[0160] Communication interface 1 enables information exchange with other devices, such as network devices;
[0161] Processor 2 is connected to communication interface 1 to enable information exchange with other devices and, when running a computer program, executes the image contour extraction method provided by one or more of the above-mentioned technical solutions. The computer program is stored in memory 3.
[0162] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 19 The general will label all buses as Bus System 4.
[0163] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0164] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0165] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0166] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0167] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0168] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0169] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0170] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. An image contour extraction method characterized by, The method comprises: acquiring a first original image along a feeding direction of a cutting machine; performing contour extraction on the first original image to obtain a contour filled image; determining a complete pattern contour and an incomplete pattern contour in the contour filled image, and outputting the complete pattern contour; cutting a to-be-stitched image corresponding to a position in the first original image based on a height range of all the incomplete pattern contours; acquiring a second original image after the first original image along the feeding direction of the cutting machine, stitching the to-be-stitched image and the second original image into a third original image, taking the third original image as the first original image again, and re-entering the step of performing contour extraction on the first original image to obtain a contour filled image, so as to realize extraction of a continuous image contour.
2. The image contour extraction method according to claim 1, wherein, The contour extraction on the first original image to obtain a contour filled image comprises: filling a background in the first original image as an inverse color of an edge line color of the first original image to obtain a first intermediate image; performing binaryzation processing on the first intermediate image to obtain a binaryzation image; wherein the background of the binaryzation image is black and the foreground is white; adding a white horizontal line with a preset number of pixels in width at the bottom of the binaryzation image to obtain a second intermediate image; determining an operation parameter of a morphological opening operation based on the preset number, and performing the morphological opening operation on the second intermediate image based on the operation parameter to obtain a to-be-extracted image, so as to convert a non-closed pattern in the second intermediate image into a closed pattern; performing contour extraction on the to-be-extracted image to obtain a contour filled image.
3. The image contour extraction method according to claim 2, wherein After adding the white horizontal line with the preset number of pixels in width at the bottom of the binaryzation image to obtain the second intermediate image, the method further comprises: performing contour extraction on the second intermediate image, and filtering the extracted contour based on a preset condition to generate an intermediate contour filled image; correspondingly, the performing of the morphological opening operation on the second intermediate image based on the operation parameter to obtain the to-be-extracted image, so as to convert the non-closed pattern in the second intermediate image into the closed pattern, comprises: performing the morphological opening operation on the intermediate contour filled image based on the operation parameter to obtain the to-be-extracted image, so as to convert a non-closed contour in the intermediate contour filled image into a closed contour; correspondingly, the contour extraction on the to-be-extracted image to obtain a contour filled image comprises: performing contour extraction on the to-be-extracted image, and filtering the extracted contour based on a preset condition to generate a contour filled image.
4. The image contour extraction method according to claim 2, wherein The determining of the complete pattern contour and the incomplete pattern contour in the contour filled image, and the outputting of the complete pattern contour, comprises: saving contour data in the contour filled image to a contour set; sequentially traversing each contour in the contour set to determine whether the contour is a complete pattern contour; if yes, saving the contour to a complete pattern contour set, and outputting the complete pattern contour in the complete pattern contour set; if no, saving the contour to an incomplete pattern contour set.
5. The image contour extraction method according to claim 4, wherein The determining of whether the contour is a complete pattern contour comprises: determining a height of the first original image, calculating a height difference between the height of the first original image and a height of the preset number of pixels; determining an incomplete contour height range between the height difference and the height of the first original pattern; judging whether there is a contour point in the contour with a height value in the incomplete contour height range; if yes, determining that the contour is an incomplete pattern contour; if no, determining that the contour is a complete pattern contour.
6. The image contour extraction method according to claim 4, wherein based on the height ranges of all the incomplete pattern contours, cutting a to-be-stitched image at a corresponding position in the first original image, comprising: determining a circumscribed rectangle of all contour points in the set of incomplete pattern contours, and determining a height range of the circumscribed rectangle; based on the height range of the circumscribed rectangle, cutting a to-be-stitched image at a corresponding position in the first original image.
7. The image contour extraction method according to claim 6, wherein the height of the first original image is less than or equal to the length of the cutting range of the cutting machine along the feeding direction; the height of the second original image is less than or equal to the difference between the length of the cutting range of the cutting machine along the feeding direction and the height of the circumscribed rectangle.
8. An image contour extracting apparatus characterized by comprising: comprising: an acquisition module configured to acquire a first original image along the feeding direction of a cutting machine a contour extraction module configured to perform contour extraction on the first original image to obtain a contour filled image; a determination module configured to determine complete pattern contours and incomplete pattern contours in the contour filled image, and output the complete pattern contours; a cutting module configured to cut a to-be-stitched image at a corresponding position in the first original image based on the height ranges of all the incomplete pattern contours; a stitching module configured to acquire a second original image after the first original image along the feeding direction of the cutting machine, stitch the to-be-stitched image and the second original image into a third original image, re-take the third original image as the first original image, and re-start the working process of the contour extraction module to realize continuous image contour extraction.
9. An electronic device, comprising: comprising: a memory configured to store a computer program; a processor configured to implement the steps of the image contour extraction method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium, and when executed by the processor, the steps of the image contour extraction method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Automatic extraction method for super-long-width cutting track of flexible materials
CN110458811A
Product cutting control method, electronic equipment and storage medium
CN116275616A
Steel plate shearing position determination method, control device, medium and electronic equipment
CN117611671A