Raw silk detection method and device based on image processing, equipment and medium
By performing region-dividing processing on the raw silk image, combining threshold extraction and feature point expansion, the problem of low quality of raw silk image caused by the global threshold method is solved, and higher quality raw silk detection is achieved.
Patent Information
- Application Number
- CN202510555767.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2045-04-29
AI Technical Summary
When the global threshold method is used in the prior art to process the raw silk picture, the quality of the raw silk picture is not high, which affects the subsequent detection effect.
The method of extracting thresholds by region is adopted to divide the raw silk images into regions, and the threshold extraction and binarization operations are performed. Combined with feature point expansion and center of gravity extraction, the center of gravity coordinates of each area are obtained as the coordinates of the defect.
It improves the quality of raw silk pictures, reduces background interference, enhances the recognition effect of slashes, and ensures the accuracy of subsequent detection.
Smart Images

Figure CN120563409A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a raw silk detection method, device, equipment and medium based on image processing. Background Art
[0002] Raw silk refers to natural fibers extracted from silkworm cocoons that have undergone preliminary processing but not further chemical treatment or refining. Raw silk is composed of fibroin and sericin, secreted by the silkworm. When the silkworm completes its larval stage and prepares to pupate, it spins a continuous, thin thread to construct a protective cocoon. The cocoons are collected and, through the reeling process, the threads from individual cocoons are combined with threads from other cocoons to form a single, continuous filament, known as raw silk.
[0003] After the raw silk is wrapped around the blackboard, it will be photographed and then processed. However, the quality of the raw silk images obtained by processing the raw silk images using the global threshold method is not high, which affects subsequent detection. Therefore, there is an urgent need to propose a better image processing method. Summary of the Invention
[0004] The present invention solves the technical problem of low quality of raw silk images obtained by processing raw silk images using a global threshold method in the prior art by providing a raw silk detection method, device, equipment and medium based on image processing, thereby achieving the technical effect of improving the quality of raw silk images.
[0005] In a first aspect, the present invention provides a method for detecting raw silk based on image processing, the method comprising:
[0006] After obtaining the raw silk image, the raw silk image is converted into a grayscale image, and the raw silk image is cropped, wherein the oblique lines are retained in the cropped raw silk image;
[0007] According to preset requirements of cleanliness detection, the raw silk image is divided into regions to obtain a plurality of first regions, each of which has the same size;
[0008] Performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique line and are smaller than the first regions;
[0009] The feature points of the second region are expanded and the center of gravity is extracted to obtain the center of gravity corresponding to each second region, and the coordinates of the center of gravity are used as the coordinates of the defect.
[0010] Furthermore, the raw silk image is cropped, including:
[0011] Perform the first cropping of the redundant background in the raw silk image;
[0012] After the raw silk images are spliced, the spaces between the silk pieces in the raw silk images are trimmed for the second time, and the oblique lines in the raw silk images are retained.
[0013] Furthermore, threshold extraction and binarization are performed on the first regions to obtain the second regions, including:
[0014] Determine a first region belonging to a background type, and remove the first region of the background type to obtain a target first region, wherein the first region of the background type does not include a slant line;
[0015] Determine the pixel with the maximum grayscale value in the first area of each target and the coordinates corresponding to the pixel;
[0016] Expand outward from the pixel point as the center to form the second area;
[0017] Each second region is binarized again using a preset threshold.
[0018] Furthermore, determining the first area belonging to the background type includes:
[0019] Determine the column standard deviation for each first region;
[0020] When the difference between the maximum value and the minimum value of the column standard deviation of the first region is greater than the first difference threshold, the first region belongs to the background type.
[0021] Furthermore, feature points of the second region are expanded, including:
[0022] Feature points of the second region are expanded based on the dilation operation, so that the size of the second region matches the actual size of the defect in the raw silk image.
[0023] Furthermore, after the feature points of the second region are expanded, the center of gravity is extracted, including:
[0024] In the target first area, determining the sum of row coordinates and the sum of column coordinates of the second area of the target first area;
[0025] Determining the row coordinates of the center of gravity of the first target area according to the total row coordinates and the number of the second areas of the first target area;
[0026] The column coordinates of the center of gravity of the first target area are determined according to the sum of the column coordinates and the number of the second areas of the first target area.
[0027] Furthermore, threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, further comprising:
[0028] Determine the maximum grayscale value and the minimum grayscale value of the first region;
[0029] If the difference between the maximum grayscale value and the minimum grayscale value of the first region is greater than a second difference threshold, the first region includes a plurality of second regions.
[0030] In a second aspect, the present invention provides a raw silk detection device based on image processing, the device comprising:
[0031] After obtaining the raw silk image, the raw silk image is converted into a grayscale image, and the raw silk image is cropped, wherein the oblique lines are retained in the cropped raw silk image;
[0032] According to preset requirements of cleanliness detection, the raw silk image is divided into regions to obtain a plurality of first regions, each of which has the same size;
[0033] Performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique line and are smaller than the first regions;
[0034] The feature points of the second region are expanded and the center of gravity is extracted to obtain the center of gravity corresponding to each second region, and the coordinates of the center of gravity are used as the coordinates of the defect.
[0035] In a third aspect, the present invention provides an electronic device, comprising:
[0036] processor;
[0037] a memory for storing processor-executable instructions;
[0038] The processor is configured to execute to implement the raw silk detection method based on image processing provided in the first aspect.
[0039] In a fourth aspect, the present invention provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to implement the raw silk detection method based on image processing as provided in the first aspect.
[0040] One or more technical solutions provided in the present invention have at least the following technical effects or advantages:
[0041] The present invention adopts a region-by-region threshold extraction method, firstly processes the image by region, and then performs threshold extraction and binarization operations on each region, thus avoiding the problem of unclear image processing caused by using a global threshold. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0043] Figure 1 A schematic diagram of the process of the raw silk detection method based on image processing provided by the present invention;
[0044] Figure 2 The original image of raw silk provided by the present invention;
[0045] Figure 3 The raw silk image after global Otsu method binarization provided by the present invention;
[0046] Figure 4 The grayscale histogram before adjustment provided by the present invention;
[0047] Figure 5 The adjusted grayscale histogram provided by the present invention;
[0048] Figure 6 The equalized grayscale histogram provided by the present invention;
[0049] Figure 7 The equalized raw silk image provided by the present invention;
[0050] Figure 8 The raw silk image after equalization and binarization provided by the present invention;
[0051] Figure 9 The raw silk image after the first cutting provided by the present invention;
[0052] Figure 10 The image of the raw silk after the second cutting provided by the present invention;
[0053] Figure 11 A raw silk image of the first region of the Otsu method provided by the present invention;
[0054] Figure 12 The raw silk image after the grayscale interpolation method provided by the present invention;
[0055] Figure 13 The raw silk image after taking the median of the standard deviation provided by the present invention;
[0056] Figure 14 The threshold value table after subtracting the maximum value provided by the present invention;
[0057] Figure 15 The raw silk image after the maximum value difference provided by the present invention;
[0058] Figure 16 An image of raw silk subjected to the expansion operation provided by the present invention;
[0059] Figure 17 This is the raw silk image after the center of gravity is extracted provided by the present invention. DETAILED DESCRIPTION
[0060] The embodiment of the present invention solves the technical problem in the prior art that the quality of raw silk images obtained by processing raw silk images using a global threshold method is low by providing a raw silk detection method based on image processing.
[0061] The technical solution of the present invention is to solve the above technical problems, and the overall idea is as follows:
[0062] A raw silk detection method based on image processing comprises: obtaining a raw silk image, converting the raw silk image into a grayscale image, and cropping the raw silk image, wherein the slant lines are retained in the cropped raw silk image; dividing the raw silk image into regions according to preset requirements for cleanliness detection to obtain a plurality of first regions, each of which has the same size; performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the slant lines and are smaller than the first regions; and performing feature point expansion and centroid extraction on the second regions to obtain the centroid corresponding to each second region, and using the coordinates of the centroid as the coordinates of the defect.
[0063] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0064] First, the term "and / or" as used herein simply describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the associated objects.
[0065] The present invention provided by the applicant is related to another patent document (2025100935229, raw silk inspection and evaluation method, device, equipment and medium based on image processing), and the related contents can be referenced together.
[0066] In addition, the applicant provides a raw silk detection method that is inferior to the following embodiment for reference:
[0067] After obtaining a raw silk image, the image is first preprocessed, including filtering and noise removal.
[0068] After ensuring that the raw silk image is input and converted into a grayscale image, the raw silk image is binarized.
[0069] Specifically, the first step is to determine the binarization threshold; the threshold is a dividing point value. When the computer processes the image, it will turn the part greater than the threshold into 1 and the part less than the threshold into 0 according to the size of the threshold, thereby completing a simple binarization operation.
[0070] Commonly used methods for finding thresholds include: bimodal method for selecting thresholds, iterative method for selecting thresholds, and Otsu method for selecting thresholds.
[0071] The bimodal method uses grayscale histogram data for judgment. When the histogram has two peaks, forming a hump-like shape, the valley between the two peaks is used as the threshold for segmentation. This method can be used to determine the threshold directly by displaying the image's grayscale histogram. It is quick and convenient, requiring no complex calculations. However, this method can result in loss of image detail.
[0072] The iterative method is a method of finding the threshold by continuously finding the maximum and minimum grayscale values in the image and calculating the average value.
[0073] Otsu's method is a commonly used method for finding a single threshold and is currently widely used. Otsu's method uses the maximum inter-class variance method to extract the threshold.
[0074] The bimodal method and iterative method are suitable for threshold extraction of images with obvious peaks and valleys in the grayscale histogram, that is, images with obvious contrast are suitable for these methods. For images with less obvious contrast, the Otsu method is more suitable for finding the threshold.
[0075] The contrast of the raw silk image is not obvious, so the Otsu method is used to perform binarization on the image. Figure 2 and Figure 3 shown.
[0076] Figure 2 This is the original image of raw silk. Figure 3 This is a raw silk image after binarization. The processed image is uneven and has too many noise points, which is not conducive to subsequent image processing.
[0077] In order to improve the image effect, you can call up the grayscale histogram of the image for observation. Figure 4 As shown in the figure, by observing the grayscale histogram, it is found that the grayscale levels in the image are mostly concentrated between 90 and 110, and present a bimodal state. The grayscale distribution is uneven, which makes it difficult to select and divide the threshold during observation and processing.
[0078] Therefore, we adjust the grayscale of the image to make the grayscale distribution more uniform and try to achieve better results. Using grayscale adjustment, we disperse the grayscale value concentration area into the range of 0 to 1.
[0079] After adjustment, the effect was still not ideal, so grayscale equalization was used to automatically adjust the image. The grayscale histogram distribution of the equalized image was more uniform, and the image contrast was stronger, making it easier to observe and process. After binarization, the image improved somewhat, but there were still problems such as uneven brightness distribution and excessive defects. Figure 4 is the histogram before adjustment, Figure 5 is the adjusted histogram, Figure 6 is the histogram after equalization.
[0080] The effect image after equalization and its binary image are as follows Figure 7 and Figure 8 shown.
[0081] Since the light reflected by the large array light source on the blackboard is uneven, it is impossible to directly process the image using a simple single threshold processing method. The reasons are as follows:
[0082] The quality of an image is closely related to its camera and light source. Since the general raw silk system (refer to the utility model filed on the same day as application number 2025100935229) uses two identical strip LED light strips as the light source, both are placed parallel to the left and right sides of the camera and move with the camera. The lighting cannot achieve uniform vertical illumination of the light on the blackboard. The light intensity in the superimposed light area is greater than that in the single beam illumination area, resulting in differences in illumination at the edges and middle of the image. Uneven light will cause the captured image of the silk piece to appear half bright and half dark.
[0083] Since the size of the blackboard is too large compared to the size of the camera and light source, image overlap will occur during the photo shooting process, which will also cause uneven grayscale of the image.
[0084] Although the raw silk image has been optimized, the above problems still exist. Therefore, the present invention provides the following improved solutions, and the specific solutions are described below.
[0085] The present invention provides Figure 1 The raw silk detection method based on image processing shown includes steps S11-S14:
[0086] Step S11 , after obtaining the raw silk image, converting the raw silk image into a grayscale image, and cropping the raw silk image, wherein the oblique lines are retained in the cropped raw silk image.
[0087] Specifically, the method includes: performing a first trimming of redundant background in the raw silk image; after the raw silk images are spliced, performing a second trimming of the gaps between silk pieces in the raw silk image, and retaining the oblique lines in the raw silk image.
[0088] Observe the original image of the raw silk. There is unwanted background on the left and top sides of the image, so it is cropped before processing. Figure 9 This is the image of raw silk after the first cut.
[0089] Although the cropped raw silk image has no extra background, there are still gaps between the silk pieces caused by the splicing process, which are still irrelevant background for oblique line recognition. Therefore, it is cropped for the second time and the oblique lines ("oblique lines" are caused by the preparation process of the raw silk blackboard. When the raw silk is wound, the head of the raw silk needs to be fixed to the side of the blackboard; then, after winding, the tail of the raw silk needs to be fixed to the side of the blackboard, so there will be many oblique lines of raw silk, which are reflected in the image as "oblique lines". In fact, they are oblique silks. The grayscale value on the image is obviously larger than other places. If it is not removed, it will be misjudged as a defect) are retained. Figure 10 This is the image of raw silk after the second cropping.
[0090] Step S12 , dividing the raw silk image into regions according to preset requirements for cleanliness detection to obtain a plurality of first regions, each of which has the same size.
[0091] After cropping, the next step is area division. In the raw silk image, one pixel represents approximately 0.1mm of actual blackboard size. Based on cleanliness testing requirements, defects typically range in size from 2 to 20mm. The middle value of 10mm was chosen as the dividing line, so a 100x100mm rectangle was used as the minimum area unit.
[0092] For example, the cropped raw silk image provided by the present invention has pixels of 800*1100. Using an area of 100*100, the image can be divided into 8*11 first areas, that is, there are 88 first areas, and each area is 100*100.
[0093] Step S13 , performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique lines and are smaller than the first regions.
[0094] Threshold extraction and binarization are performed on several first areas to obtain several second areas, including: determining the first area belonging to the background type, and eliminating the first area of the background type to obtain the target first area, wherein the first area of the background type does not include a slant line; determining the pixel point with the largest grayscale value in each target first area and the coordinates corresponding to the pixel point; expanding outward from the pixel point as the center to form the second area; and binarizing each second area again with a preset threshold.
[0095] After the first region is determined, the present invention also provides multiple methods for threshold extraction and binarization. Please refer to the following for details:
[0096]
Method 1
[0097] Directly use the Otsu method to extract the threshold of the first area. The specific effect is as follows: Figure 11 shown.
[0098] Figure 11 Several first regions can be observed in the image, and the position of the diagonal line can be clearly seen. However, the drawback is that there are too many defects and it is difficult to extract the relevant points on the diagonal line, which makes subsequent processing difficult.
[0099] By observing the threshold of each block, it can be found that the threshold of the block located on the oblique line is significantly different from that of other background parts. The reason is that the oblique line is obviously white, which increases its grayscale and causes unevenness, while the grayscale of other parts is relatively uniform.
[0100] Therefore, the present invention proposes that threshold extraction can be performed only on the first area where the oblique line passes, while ignoring other parts. For details, please refer to the following method.
[0101]
Method 2
[0102] Threshold extraction and binarization are performed on several first areas to obtain several second areas, and the method also includes: determining the maximum grayscale value and the minimum grayscale value of the first area; if the difference between the maximum grayscale value and the minimum grayscale value of the first area is greater than a second difference threshold, then the several second areas are included.
[0103] Take the maximum and minimum grayscale values of each first area and subtract them. If the obtained value is greater than the second preset difference, it is considered that the grayscale of the first area is uneven; if it is less than this value, the grayscale value of the first area is set to 0, so as to highlight the oblique line part and weaken the interference of the background. Figure 12 shown.
[0104] from Figure 12 It can be seen that the image effect is greatly improved, most of the diagonal area is retained, and the background interference is reduced, but the interference problem of redundant defects still exists.
[0105] Therefore, it can be judged that only using the maximum and minimum grayscale differences for judgment is too general and cannot handle the details. If the grayscale differences between some first areas are very close, incorrect judgment will occur. The selection of the judgment value also adopts the method of taking the middle value, which is not accurate enough.
[0106] To address this problem, the present invention provides [Method 3]
[0107] The standard deviation is used instead of the difference between the maximum and minimum values for judgment. The standard deviation indicates the degree of dispersion of the data within the group, and the fluctuation of the data results can be seen.
[0108]
[0109] Where δ is the standard deviation, x i is the i-th data, is the data average, and N is the number of data.
[0110] Since we are dealing with a matrix, the standard deviation can be calculated by row or column. If we calculate by row, it will cause a large error due to uneven illumination in the horizontal direction, so we can use the column direction to calculate. Use the standard deviation calculation function to calculate, and select the middle value of the calculation result as the judgment value for block processing. The effect diagram is as follows Figure 13 shown.
[0111] from Figure 13 It's clear that the processed image has been greatly improved, with background interference artifacts significantly reduced. However, interference artifacts still remain in the upper right corner, and the diagonal line is no longer complete. Only a few characteristic points remain on the leftmost diagonal line, which can easily be confused with interference points, hindering subsequent processing.
[0112] In view of this, the present invention also provides [Method 4]: determining a first area belonging to a background type, comprising: determining a column standard deviation of each first area; when the difference between the maximum and minimum values of the column standard deviation of the first area is greater than a first difference threshold, the first area belongs to the background type.
[0113] In [Method 3], taking the median value is not detailed enough for blocks with 100 columns. The standard deviation values in a block may be very close, leading to misjudgment. The algorithm is optimized using the extreme value difference method. The maximum and minimum column standard deviations of each first region are subtracted. If the resulting value is greater than the first difference threshold, it is considered uneven; if it is less than the first difference threshold, it is considered background. Taking the extreme value difference method can provide more accurate judgment.
[0114] Since the light source in the shooting environment is relatively stable and there are few other light interference issues, it can be considered as a standard state. Figure 14 The difference between the maximum and minimum column standard deviations of a number of first regions. Based on the data in the table, the standard deviation of the first region through which the diagonal line passes is generally above 3. Therefore, 3.2 is selected as the demarcation criterion to eliminate background interference and facilitate the extraction of the diagonal line. Figure 15 This is the effect diagram of method [4].
[0115] Depend on Figure 15It can be seen that the basic shape of the three oblique lines is preserved intact, and the background removal effect is good.
[0116] Although the raw silk image currently obtained has removed most of the background interference and the diagonal line can be observed more clearly, there are still many defects in the blocks where the diagonal line passes, which is not conducive to subsequent calculation and processing.
[0117] By observing the grayscale values of the image and pixels, it can be found that the grayscale value of the oblique line is the highest in the block where the oblique line passes, basically belonging to the numerical range above 240, which is quite different from the grayscale value of the background. The feature (grayscale value 240) can be used to extract the oblique line.
[0118] Specifically, if the standard deviation within a first region is greater than a first difference threshold, the region is considered to be an uneven area (i.e., a non-background area) where the diagonal line may pass. Further analysis is performed within this region, selecting the pixel with the maximum grayscale value and extracting its coordinates. At this grayscale maximum, a small region is created and its grayscale value is artificially set to 255. Binarization is then performed again, with a threshold of 0.5-0.7. A higher threshold can better remove interference from other defects and retain the processed points.
[0119] The coordinate point where the maximum grayscale value in the first area is located is a pixel, and the display effect is poor, so its display area is increased, and a small area is opened up at the coordinate position where the maximum value is located. The expanded area is the second area. The size of the second area should not be too large, and can be determined based on actual conditions.
[0120] After completing the above steps, the effect of the raw silk image is improved, the characteristic points of the diagonal lines are retained, and the surrounding interference points are basically eliminated.
[0121] However, the size of the characteristic point of the oblique line is too small and does not match the actual defect size. Therefore, step S14 can be executed.
[0122] In step S14, feature point expansion and centroid extraction are performed on the second region to obtain the centroid corresponding to each second region, and the coordinates of the centroid are used as the coordinates of the defect.
[0123] Specifically, the method includes: expanding the feature points of the second region based on a dilation operation, so that the size of the second region matches the actual size of the defect in the raw silk image.
[0124] After the feature points of the second area are expanded, the center of gravity is extracted, including: in the target first area, determining the sum of the row coordinates and the sum of the column coordinates of the second area of the target first area; determining the row coordinates of the center of gravity of the target first area according to the sum of the row coordinates and the number of the second areas of the target first area; and determining the column coordinates of the center of gravity of the target first area according to the sum of the column coordinates and the number of the second areas of the target first area.
[0125] Dilation: Shift the structuring element by a unit size within the image matrix, and take the result whose intersection with the image matrix is not empty. In other words, the result of dilation is the set of results obtained by ORing the two matrices.
[0126] This paper chooses to perform dilation operation to expand the range of feature points to match the actual defect size. When creating the structural element matrix, select the circle as the shape, and the effect is as follows: Figure 16 shown.
[0127] The image after dilation processing has achieved good results. However, it is not possible to perform subsequent operations on a region. It is necessary to identify the coordinates of the feature points before continuing the operation and processing. Therefore, the center of gravity of each first region can be extracted based on the center of gravity extraction method. The effect diagram is as follows Figure 17 shown.
[0128] In summary, the present invention provides a raw silk inspection method based on image processing, comprising: obtaining a raw silk image, converting the raw silk image into a grayscale image, and cropping the raw silk image, wherein the cropped raw silk image retains the diagonal lines; dividing the raw silk image into regions according to preset requirements for cleanliness inspection to obtain a plurality of first regions, each of which is of the same size; performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions; and performing feature point expansion and centroid extraction on the second regions to obtain the centroid corresponding to each second region, and using the coordinates of the centroid as the coordinates of the defect. The present invention adopts a region-by-region threshold extraction method, first processing the image by region, and then performing threshold extraction and binarization on each region, thereby avoiding the problem of unclear image processing caused by using a global threshold.
[0129] Based on the same inventive concept, the present invention also provides a raw silk detection device based on image processing, the device comprising:
[0130] After obtaining the raw silk image, the raw silk image is converted into a grayscale image, and the raw silk image is cropped, wherein the oblique lines are retained in the cropped raw silk image;
[0131] According to preset requirements of cleanliness detection, the raw silk image is divided into regions to obtain a plurality of first regions, each of which has the same size;
[0132] Performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique line and are smaller than the first regions;
[0133] The feature points of the second region are expanded and the center of gravity is extracted to obtain the center of gravity corresponding to each second region, and the coordinates of the center of gravity are used as the coordinates of the defect.
[0134] Based on the same inventive concept, the present application also provides an electronic device, including:
[0135] processor;
[0136] a memory for storing processor-executable instructions;
[0137] The processor is configured to execute to implement the raw silk detection method based on image processing as provided above.
[0138] Based on the same inventive concept, the present application also provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by the processor of an electronic device, the electronic device can implement the raw silk detection method based on image processing as provided above.
[0139] Since the electronic device described in this embodiment is an electronic device used to implement the information processing method in the embodiment of the present invention, based on the information processing method described in the embodiment of the present invention, those skilled in the art will be able to understand the specific implementation of the electronic device of this embodiment and its various variations. Therefore, how the electronic device implements the method in the embodiment of the present invention will not be described in detail here. As long as the electronic device used by those skilled in the art to implement the information processing method in the embodiment of the present invention falls within the scope of protection of the present invention.
[0140] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0141] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0142] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0143] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0144] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0145] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A raw silk detection method based on image processing, characterized in that: The method comprises: After obtaining the raw silk image, the raw silk image is converted into a grayscale image, and the raw silk image is cropped, wherein the oblique lines are retained in the cropped raw silk image; According to preset requirements of cleanliness detection, the raw silk image is divided into regions to obtain a plurality of first regions, each of which has the same size; Performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique line and are smaller than the first regions; The feature points of the second region are expanded and the center of gravity is extracted to obtain the center of gravity corresponding to each second region, and the coordinates of the center of gravity are used as the coordinates of the defect.
2. The raw silk detection method based on image processing according to claim 1, characterized in that: Cropping of raw silk images, including: Perform the first cropping of the redundant background in the raw silk image; After the raw silk images are spliced, the spaces between the silk pieces in the raw silk images are trimmed for the second time, and the oblique lines in the raw silk images are retained.
3. The raw silk detection method based on image processing according to claim 1, characterized in that: Threshold extraction and binarization are performed on the first regions to obtain the second regions, including: Determine a first region belonging to a background type, and remove the first region of the background type to obtain a target first region, wherein the first region of the background type does not include a slant line; Determine the pixel with the maximum grayscale value in the first area of each target and the coordinates corresponding to the pixel; Expand outward from the pixel point as the center to form the second area; Each second region is binarized again using a preset threshold.
4. The raw silk detection method based on image processing according to claim 3, characterized in that: Determine a first region belonging to the background type, including: Determine the column standard deviation for each first region; When the difference between the maximum value and the minimum value of the column standard deviation of the first region is greater than the first difference threshold, the first region belongs to the background type.
5. The raw silk detection method based on image processing according to claim 1, characterized in that: Expand the feature points of the second area, including: Feature points of the second region are expanded based on the dilation operation, so that the size of the second region matches the actual size of the defect in the raw silk image.
6. The raw silk detection method based on image processing according to claim 3, characterized in that: After expanding the feature points of the second area, the center of gravity is extracted, including: In the target first area, determining the sum of row coordinates and the sum of column coordinates of the second area of the target first area; Determining the row coordinates of the center of gravity of the first target area according to the total row coordinates and the number of the second areas of the first target area; The column coordinates of the center of gravity of the first target area are determined according to the sum of the column coordinates and the number of the second areas of the first target area.
7. The raw silk detection method based on image processing according to claim 1, characterized in that: Threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, further comprising: Determine the maximum grayscale value and the minimum grayscale value of the first region; If the difference between the maximum grayscale value and the minimum grayscale value of the first region is greater than a second difference threshold, the first region includes a plurality of second regions.
8. A raw silk detection device based on image processing, characterized in that: The device comprises: After obtaining the raw silk image, the raw silk image is converted into a grayscale image, and the raw silk image is cropped, wherein the oblique lines are retained in the cropped raw silk image; According to preset requirements of cleanliness detection, the raw silk image is divided into regions to obtain a plurality of first regions, each of which has the same size; Performing threshold extraction and binarization on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to the oblique line and are smaller than the first regions; The feature points of the second region are expanded and the center of gravity is extracted to obtain the center of gravity corresponding to each second region, and the coordinates of the center of gravity are used as the coordinates of the defect.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute to implement the raw silk detection method based on image processing according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to implement the raw silk detection method based on image processing according to any one of claims 1 to 7.
Citation Information
Patent Citations
Gas turbine blade defects extraction and analysis method based on region segmenting detection
CN104730091A
Stain area detection method and device, analytical instrument and storage medium
CN108765424A
Raw silk quality detection device and method
CN109297979A
Image background area detection method and device, storage medium and X-ray system
CN110163857A
Metal luster area-based steel wire rope defect detection method
CN114049316A