Image processing-based raw silk detection method, device, equipment and medium

By performing regional processing and feature point expansion on raw silk images, the problem of low image quality caused by the global thresholding method is solved, and higher quality raw silk detection is achieved.

CN120563409BActive Publication Date: 2025-12-16SICHUAN FIBER INSPECTION BUREAU +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510555767.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-12-16
Estimated Expiration
2045-04-29

AI Technical Summary

Technical Problem

In existing technologies, the global thresholding method is used to process raw silk images, resulting in low image quality and affecting subsequent detection results.

Method used

The method of extracting thresholds by region is adopted. First, the raw silk image is divided into regions. Then, threshold extraction and binarization are performed on each region. Combined with feature point expansion and centroid extraction, the centroid coordinates of the raw silk image are obtained.

Benefits of technology

It improves the quality, clarity, and accuracy of raw silk images, reduces background interference, and enhances the reliability of subsequent testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120563409B_ABST
    Figure CN120563409B_ABST
Patent Text Reader

Abstract

The application discloses a raw silk detection method, device and equipment based on image processing and a medium, and comprises the following steps: after a raw silk image is acquired, the raw silk image is converted into a gray-scale image, and the raw silk image is cropped; according to a cleanliness detection preset requirement, the raw silk image is regionally divided to obtain a plurality of first regions, and each first region is of the same size; threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, wherein the second regions are related to diagonal lines, and the second regions are smaller than the first regions; feature point expansion and barycenter extraction are performed on the second regions to obtain the barycenter corresponding to each second region, and the coordinates of the barycenter are taken as the coordinates of a defect. The application belongs to the field of image processing. The application improves the image processing quality through regional division.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more particularly to a method, apparatus, device, and medium for detecting raw silk based on image processing. Background Technology

[0002] Raw silk refers to the natural fiber extracted from silkworm cocoons, which has undergone preliminary processing but has not undergone 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 stream of fine silk threads to build a protective cocoon. The cocoons can be collected and the silk threads from individual cocoons are combined with those from other cocoons into a single continuous filament, i.e., raw silk, through the silk reeling process.

[0003] After the raw silk is wrapped around the blackboard, the raw silk is photographed and then the image is processed. However, the raw silk image obtained by the current global thresholding method is of low quality, which affects the subsequent detection. Therefore, there is an urgent need to propose a better image processing method. Summary of the Invention

[0004] This invention provides a raw silk detection method, apparatus, device, and medium based on image processing, which solves the technical problem of low quality of raw silk images obtained by processing raw silk images using the global threshold method in the prior art, and achieves the technical effect of improving the quality of raw silk images.

[0005] In a first aspect, the present invention provides a raw silk detection method based on image processing, the method comprising:

[0006] After acquiring the raw silk image, the raw silk image is converted into a grayscale image and then cropped. The cropped raw silk image retains the diagonal lines.

[0007] According to the preset requirements for cleanliness testing, the raw silk image is divided into regions to obtain several first regions, and each first region is the same size.

[0008] Threshold extraction and binarization are performed on several first regions to obtain several second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions;

[0009] The second region is expanded by feature points and the centroid is extracted to obtain the centroid corresponding to each second region, and the coordinates of the centroid are used as the coordinates of the defect.

[0010] Furthermore, the raw silk image is cropped, including:

[0011] The excess background in the raw silk image is first cropped;

[0012] After the raw silk images are stitched together, the gaps between the silk pieces in the raw silk images are trimmed a second time, while retaining the diagonal lines in the raw silk images.

[0013] Furthermore, threshold extraction and binarization are performed on several first regions to obtain several second regions, including:

[0014] Identify the first region belonging to the background type, and remove the first region of the background type to obtain the target first region. The first region of the background type does not include diagonal lines.

[0015] Determine the pixel with the highest grayscale value in the first region of each target and the coordinates of that pixel;

[0016] The second region is expanded outward from the center of this pixel.

[0017] Each second region is binarized again using a preset threshold.

[0018] Further, the first region belonging to the background type is identified, including:

[0019] Determine the column standard deviation for each first region;

[0020] When the difference between the maximum and minimum values ​​of the column standard deviations in the first region is greater than the first difference threshold, the first region belongs to the background type.

[0021] Furthermore, the feature points of the second region are expanded, including:

[0022] The second region is expanded by dilation operation to make the size of the second region match the actual size of the defects in the raw silk image.

[0023] Furthermore, after expanding the feature points of the second region, centroid extraction is performed, including:

[0024] Within the first region of the target, determine the sum of the row coordinates and the sum of the column coordinates of the second region of the first region of the target;

[0025] The centroid row coordinates of the first region of the target are determined based on the sum of the row coordinates and the number of second regions in the first region of the target.

[0026] The column coordinates of the centroid of the first region of the target are determined based on the sum of the column coordinates and the number of second regions in the first region of the target.

[0027] Furthermore, threshold extraction and binarization are performed on several first regions to obtain several second regions, which also include:

[0028] Determine the maximum and minimum grayscale values ​​of the first region;

[0029] If the difference between the maximum and minimum grayscale values ​​of the first region is greater than a second difference threshold, then the region includes several second regions.

[0030] Secondly, the present invention provides an image processing-based raw silk detection device, the device comprising:

[0031] After acquiring the raw silk image, the raw silk image is converted into a grayscale image and then cropped. The cropped raw silk image retains the diagonal lines.

[0032] According to the preset requirements for cleanliness testing, the raw silk image is divided into regions to obtain several first regions, and each first region is the same size.

[0033] Threshold extraction and binarization are performed on several first regions to obtain several second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions;

[0034] The second region is expanded by feature points and the centroid is extracted to obtain the centroid corresponding to each second region, and the coordinates of the centroid are used as the coordinates of the defect.

[0035] Thirdly, the present invention provides an electronic device, comprising:

[0036] processor;

[0037] Memory used to store processor-executable instructions;

[0038] The processor is configured to execute the image processing-based raw silk detection method as provided in the first aspect.

[0039] Fourthly, the present invention provides a non-transitory computer-readable storage medium that, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the image processing-based raw silk detection method as provided in the first aspect.

[0040] One or more technical solutions provided in this invention have at least the following technical effects or advantages:

[0041] This invention employs a region-based threshold extraction method. First, the image is divided into regions for processing, and then each region undergoes its own threshold extraction and binarization operation, thus avoiding the problem of unclear image processing caused by using a global threshold. Attached Figure Description

[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0043] Figure 1 A schematic flowchart of the image processing-based raw silk detection method provided by the present invention;

[0044] Figure 2 The original image of raw silk provided by this invention;

[0045] Figure 3 This is a raw silk image after global Otsu method binarization provided by the present invention;

[0046] Figure 4 The grayscale histogram before adjustment provided by this invention;

[0047] Figure 5 The adjusted grayscale histogram provided by this invention;

[0048] Figure 6 The equalized grayscale histogram provided by this invention;

[0049] Figure 7 The image of the raw silk after equalization provided by this invention;

[0050] Figure 8 This is an equalized and binarized raw silk image provided by the present invention;

[0051] Figure 9 The image provided by this invention is of the raw silk after the first cut;

[0052] Figure 10 The image provided by this invention shows the raw silk after the second cutting.

[0053] Figure 11 An image of raw silk in the first region of the Otsu process provided by this invention;

[0054] Figure 12 The image of raw silk after grayscale interpolation provided by this invention;

[0055] Figure 13 The raw silk image provided by this invention after taking the median of the standard deviation;

[0056] Figure 14 The threshold table provided by this invention after subtracting the extreme values;

[0057] Figure 15 The image of raw silk after subtracting the extreme values ​​provided by this invention;

[0058] Figure 16 Images of raw silk undergoing expansion operations provided by this invention;

[0059] Figure 17 The image of raw silk after center of gravity extraction is provided by the present invention. Detailed Implementation

[0060] This invention provides a raw silk detection method based on image processing, which solves the technical problem that the raw silk images obtained by processing raw silk images using the global threshold method in the prior art are of low quality.

[0061] The technical solution of this invention is to solve the above-mentioned technical problems, and the overall idea is as follows:

[0062] A raw silk detection method based on image processing includes: acquiring 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 the preset cleanliness detection requirements to obtain several first regions, each of which is the same size; performing threshold extraction and binarization on the several first regions to obtain several second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions; expanding the second regions by feature points and extracting the centroid to obtain the centroid corresponding to each second region, and using the coordinates of the centroid as the coordinates of the defect.

[0063] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0064] First, it should be clarified that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0065] The present invention provided by the applicant is related to another patent document (2025100935229, Method, Apparatus, Equipment and Medium for Raw Silk Inspection and Evaluation Based on Image Processing), and the related contents can be referred to together.

[0066] In addition, the applicant provides a raw silk testing method that is inferior to the following embodiments for reference:

[0067] After obtaining a raw silk image, the first step is to perform preprocessing, including filtering and noise reduction.

[0068] Once the input raw silk image is confirmed and converted to grayscale, 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 an image, it will turn the part greater than the threshold into 1 and the part less than the threshold into 0, thereby completing a simple binarization operation.

[0070] Commonly used methods for finding thresholds include: the bimodal method, the iterative method, and the Otsu method.

[0071] The bimodal method uses grayscale histogram data to determine the threshold. When the histogram has two peaks, exhibiting a camel-hump shape, the trough between the two peaks is selected as the threshold for classification. This method allows for direct observation of the image's grayscale histogram to obtain the threshold, offering convenience and speed without complex calculations. However, this can lead to a loss of image detail.

[0072] The iterative method is a method that uses the maximum and minimum gray values ​​in an image to calculate the average value in order to find the threshold.

[0073] Otsu's method is a commonly used and widely applied approach for finding single threshold values. Otsu's method employs the maximum inter-class variance method for threshold extraction.

[0074] The bimodal and iterative methods are suitable for threshold extraction of images with obvious peaks and troughs in their grayscale histograms, i.e., images with high contrast are well-suited to these methods. However, for images with low contrast, the Otsu method is more suitable for finding the threshold.

[0075] Since the contrast in the raw silk image is not obvious, Otsu's method is used for image binarization. The original raw silk image and the binarized image are shown below. Figure 2 and Figure 3 As shown.

[0076] Figure 2 This is the original image of raw silk. Figure 3 This is a binarized image of raw silk. The processed image is uneven and contains too many noise points, which is detrimental to subsequent image processing.

[0077] To improve image quality, you can view the image's grayscale histogram for observation. For example... Figure 4 As shown, observation of the grayscale histogram reveals that most grayscale levels in the image are concentrated between 90 and 110, exhibiting a bimodal distribution and uneven grayscale distribution. This makes it difficult to select and classify thresholds during observation and processing.

[0078] Therefore, grayscale adjustment is performed on the image to make the grayscale level distribution more uniform and to try to achieve a better effect. Grayscale adjustment is used to disperse the concentrated grayscale value areas into the 0 to 1 range.

[0079] The adjustment was still not ideal, so grayscale equalization was applied to the image for automatic adjustment. After equalization, the grayscale histogram distribution of the image was more uniform, and the image contrast was stronger, making it easier to observe and process. After binarization, the image was improved, but problems such as uneven brightness distribution and too many defects still existed. Figure 4 This is the histogram before adjustment. Figure 5 This is the adjusted histogram. Figure 6 This is the histogram after equalization.

[0080] The equalized result and its binarized image are as follows: Figure 7 and Figure 8 As shown.

[0081] Because the light reflected from a large-area light source on a blackboard is uneven, a simple single-threshold processing method cannot be used to directly process the image. The reasons are as follows:

[0082] The quality of an image is closely related to its camera and light source. Typical raw silk lighting systems (see the utility model filed on the same day as application number 2025100935229) use two identical strip-shaped LED lights as the light source, placed parallel to each other on the left and right sides of the camera and moving with it. This lighting method cannot achieve uniform, perpendicular illumination of the blackboard; the light intensity in the overlapping areas is greater than that in areas illuminated by a single beam, resulting in differences in illumination between the edges and the center of the image. Uneven lighting will cause the captured image of the silk sheet to appear half bright and half dark.

[0083] Because the blackboard is much larger than the camera and light source, image superposition will occur during the photo taking process, which will also cause uneven grayscale in the image.

[0084] Despite optimization of the raw silk image, the aforementioned problems persist. Therefore, the present invention provides the following improvement, the details of which are described below.

[0085] This invention provides, for example Figure 1 The image processing-based raw silk detection method shown includes steps S11-S14:

[0086] Step S11: After obtaining the raw silk image, convert the raw silk image into a grayscale image and crop the raw silk image, wherein the diagonal lines are retained in the cropped raw silk image.

[0087] Specifically, this includes: first cropping the excess background in the raw silk image; and after the raw silk images are stitched together, second cropping the gaps between the silk pieces in the raw silk image while retaining the diagonal lines in the raw silk image.

[0088] Observing the original image of raw silk, unwanted background is present on the left and top sides, so it needs to be pre-cropped before processing. Figure 9 This is an image of the raw silk after the first cut.

[0089] Although the cut raw silk image no longer has extra background, there are still gaps between the silk pieces due to the splicing process. These gaps are still irrelevant background for diagonal line recognition, so a second cut is performed. The diagonal lines (these are produced during the preparation 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 it is wound. After the winding is finished, the tail of the raw silk needs to be fixed to the side of the blackboard, which results in many diagonal lines. They appear as diagonal lines in the image, but are actually diagonal silk. Their grayscale value is significantly higher than other areas. If they are not removed, they will be misjudged as defects) are retained. Figure 10 Image of raw silk after the second cutting.

[0090] Step S12: According to the preset requirements for cleanliness detection, the raw silk image is divided into regions to obtain several first regions, and each first region is the same size.

[0091] After cutting, the next step is to divide the area. In the raw silk image, one pixel unit represents an actual blackboard size of approximately 0.1mm. According to the cleanliness inspection requirements, the size of defects is generally between 2 and 20mm. We selected a value close to the middle, 10mm, as the dividing basis, so a 100*100mm rectangular block was used as the smallest unit of the area.

[0092] For example, the cut raw silk image provided by the present invention has a pixel size of 800*1100. Using a region of 100*100, the image can be divided into 8*11 first regions, that is, there are 88 first regions, and each region is 100*100.

[0093] Step S13: Threshold extraction and binarization are performed on several first regions to obtain several second regions, wherein the second regions are related to the diagonal line and the second regions are smaller than the first regions.

[0094] Thresholding and binarization are performed on several first regions to obtain several second regions, including: identifying first regions belonging to the background type and removing the first regions of the background type to obtain target first regions, wherein the first regions of the background type do not include diagonal lines; identifying the pixel with the largest gray value in each target first region and the coordinates of the corresponding pixel; expanding outward from the pixel as the center to form second regions; and binarizing each second region again with a preset threshold.

[0095] Having identified the first region, this invention also provides various methods for threshold extraction and binarization, as detailed below:

[0096] Method 1

[0097] The threshold of the first region is extracted directly using the Otsu method, and the specific results are as follows: Figure 11 As shown.

[0098] Figure 11 Several first regions can be observed, and the position of the diagonal lines can be clearly seen. However, the drawback is that there are too many defects to extract the relevant points on the diagonal lines, 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 diagonal line is significantly different from other background parts. This is because the diagonal line is obviously white, which increases its gray level and causes unevenness, while the gray level of other parts is relatively uniform.

[0100] Therefore, this invention proposes that threshold extraction can be performed only on the first region through which the diagonal line passes, while ignoring the other parts. For details, please refer to the following method.

[0101] Method 2

[0102] Threshold extraction and binarization are performed on several first regions to obtain several second regions. The method also includes: determining the maximum and minimum gray values ​​of the first regions; if the difference between the maximum and minimum gray values ​​of the first regions is greater than a second difference threshold, then the method includes several second regions.

[0103] The maximum and minimum grayscale values ​​of each first region are subtracted. If the resulting value is greater than a second preset difference, the first region is considered to have uneven grayscale; if it is less than this value, the grayscale value of that first region is set to 0. This highlights the diagonal lines and weakens the interference of the background. Specifically, as shown below... Figure 12 As shown.

[0104] from Figure 12 As can be seen, the image quality has been greatly improved, most of the diagonal lines have been preserved, and background interference has been reduced, but there are still interference issues caused by extra defects.

[0105] Therefore, it can be determined that using only the maximum and minimum grayscale difference for judgment is too general and cannot handle details. If the grayscale difference between some first regions is very close, judgment errors will occur. The selection of the judgment value also adopts the method of taking the median value, which is not precise 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 represents the degree of dispersion of the data within the group and can show the magnitude of the fluctuation in the data results.

[0108]

[0109] Where δ is the standard deviation, x i For the i-th data, Let N be the average value of the data, and N be the number of data points.

[0110] Since we are dealing with a matrix, the standard deviation can be calculated row-wise or column-wise. Calculating by row can introduce significant errors due to uneven horizontal lighting, so calculating by column is preferable. Using the standard deviation calculation function, the median value of the result is selected as the criterion for block processing. The resulting image is shown below. Figure 13 As shown.

[0111] from Figure 13 It is clear that the processed image has been greatly improved, with a significant reduction in background interference. However, interference remains in the upper right corner, and the diagonal lines are no longer complete. The leftmost diagonal line only has a few feature points, which are easily confused with interference points, hindering subsequent processing.

[0112] In view of this, the present invention also provides [Method 4]: determining a first region belonging to the background type, including: determining the column standard deviation of each first region; when the difference between the maximum and minimum values ​​of the column standard deviation of the first region is greater than a first difference threshold, the first region belongs to the background type.

[0113] In Method 3, the method of taking the median value is not precise enough for blocks with 100 columns, as the standard deviations in some blocks may be very close, leading to misclassification. The algorithm is optimized by subtracting the maximum and minimum standard deviations of each column in the first region. If the result is greater than a first difference threshold, it is considered uneven; if it is less than the first difference threshold, it is considered background. This method of subtracting the extreme values ​​of standard deviations allows for more accurate judgment.

[0114] Because the ambient light source is relatively stable during shooting, and there are few other light interference issues, it can be considered a standard condition. For example... Figure 14 This represents the difference between the maximum and minimum standard deviations of several first regions. Based on the data in the table, the standard deviation of the first region traversed by the diagonal line is generally above 3. Therefore, 3.2 is selected as the boundary standard for judgment, eliminating background interference and facilitating the extraction of the diagonal line portion. Figure 15 The result of method [4] is shown in the figure.

[0115] Depend on Figure 15As can be seen, the basic shape of the three diagonal lines is preserved intact, and the background removal effect is good.

[0116] Although the current raw silk images have removed most of the background interference, and the diagonal lines are relatively easy to observe, there are still many defects within the blocks traversed by the diagonal lines, which is detrimental to subsequent calculations and processing.

[0117] By observing the grayscale values ​​of the image and pixels, it can be found that the grayscale value of the diagonal line is the highest within the block through which the diagonal line passes, basically falling into the range of values ​​above 240. There is a significant difference between the grayscale value and the background grayscale value. The feature (grayscale value 240) can be used to extract the diagonal line.

[0118] Specifically, this involves: if the standard deviation within a certain first region is greater than a first difference threshold, this first region is considered to be an uneven region (i.e., a non-background region) that the diagonal line may pass through. Further judgment is performed within this region, selecting the pixel with the highest grayscale value and extracting its coordinates. At this point with the highest grayscale value, a small region is created, and its grayscale value is manually set to 255. Then, a second binarization process is performed, with a threshold of 0.5-0.7. A higher threshold allows for better removal of interference from other defects, preserving the processed points.

[0119] The coordinates of the maximum grayscale value in the first region are one pixel, resulting in poor display quality. Therefore, the display area is increased by creating a small area at the coordinates of the maximum value. This expanded area is the second region. The size of the second region should not be too large and can be determined based on the actual situation.

[0120] After the above steps, the effect of the raw silk image is improved, the feature points of the diagonal lines are preserved, and the surrounding interference points are basically eliminated.

[0121] However, the size of the feature points on the diagonal lines is too small and does not match the actual size of the defects. Therefore, step S14 can be performed.

[0122] Step S14: Expand the feature points and extract the centroid of the second region to obtain the centroid of each second region, and use the coordinates of the centroid as the coordinates of the defect.

[0123] Specifically, this includes: expanding the feature points of the second region based on the dilation operation so that the size of the second region matches the actual size of the defects in the raw silk image.

[0124] After expanding the feature points of the second region, centroid extraction is performed, including: in the target first region, determining the sum of row coordinates and the sum of column coordinates of the second region of the target first region; determining the centroid row coordinates of the target first region based on the sum of row coordinates and the number of second regions of the target first region; and determining the centroid column coordinates of the target first region based on the sum of column coordinates and the number of second regions of the target first region.

[0125] Dilation operation: The structuring element is shifted by a unit size within the image matrix, and the result is the value whose intersection with the image matrix is ​​not empty. In other words, the result of dilation is the set of results obtained by performing a bitwise OR operation on two matrices.

[0126] This paper chooses to perform a dilation operation to expand the range of feature points, making it consistent with the actual size of the defects. When creating the structuring element matrix, dots are selected as the shape, and the resulting image is shown below. Figure 16 As shown.

[0127] The image after dilation achieved good results. However, subsequent operations cannot be performed on a single region; the coordinates of feature points need to be identified before further processing. Therefore, centroid extraction can be used to extract the centroid of each first region, resulting in the following image. Figure 17 As shown.

[0128] In summary, this invention provides an image processing-based raw silk detection method. The method includes: acquiring 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 a preset cleanliness detection requirement, obtaining several first regions of the same size; performing threshold extraction and binarization on the several first regions to obtain several second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions; expanding the feature points and extracting the centroids of the second regions to obtain the centroids corresponding to each second region, and using the coordinates of the centroids as the coordinates of the defects. This invention adopts a region-based threshold extraction method, first dividing the image into regions, and then performing threshold extraction and binarization operations on each region separately, 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 an image processing-based raw silk detection device, the device comprising:

[0130] After acquiring the raw silk image, the raw silk image is converted into a grayscale image and then cropped. The cropped raw silk image retains the diagonal lines.

[0131] According to the preset requirements for cleanliness testing, the raw silk image is divided into regions to obtain several first regions, and each first region is the same size.

[0132] Threshold extraction and binarization are performed on several first regions to obtain several second regions, wherein the second regions are related to the diagonal lines and are smaller than the first regions;

[0133] The second region is expanded by feature points and the centroid is extracted to obtain the centroid corresponding to each second region, and the coordinates of the centroid are used as the coordinates of the defect.

[0134] Based on the same inventive concept, this application also provides an electronic device, including:

[0135] processor;

[0136] Memory used to store processor-executable instructions;

[0137] The processor is configured to execute the image processing-based raw silk detection method as described above.

[0138] Based on the same inventive concept, this application also provides a non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to perform the image processing-based raw silk detection method as described above.

[0139] Since the electronic device described in this embodiment is an electronic device used to implement the information processing method in the embodiments of the present invention, those skilled in the art can understand the specific implementation methods and various variations of the electronic device in this embodiment based on the information processing method described in the embodiments of the present invention. Therefore, how the electronic device implements the method in the embodiments of the present invention will not be described in detail here. Any electronic device used by those skilled in the art to implement the information processing method in the embodiments of the present invention falls within the scope of protection of the present invention.

[0140] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0141] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations 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, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0142] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0143] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0144] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0145] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A method for detecting raw silk based on image processing, characterized in that, The method comprises: After obtaining the raw silk image, the raw silk image is converted into a gray image, and the raw silk image is cropped, wherein the slant line is retained in the cropped raw silk image, and the cropping of the raw silk image comprises: first cropping the redundant background in the raw silk image; after the raw silk image is spliced, the interval gap between the silk pieces in the raw silk image is secondly cropped, and the slant line in the raw silk image is retained; According to the preset requirement of cleanliness detection, the raw silk image is regionally divided to obtain a plurality of first regions, and each first region is of the same size; Threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, wherein the second region is related to the slant line and the second region is smaller than the first region, comprising: determining the first region belonging to the background type, and eliminating the first region of the background type to obtain a target first region, wherein the slant line is not included in the first region of the background type; determining the pixel point with the maximum gray value in each target first region and the coordinates corresponding to the pixel point; the second region is expanded outwardly with the pixel point as the center; the second region is binarized again with a preset threshold; Feature point expansion and gravity center extraction are performed on the second region to obtain the gravity center corresponding to each second region, and the coordinates of the gravity center are taken as the coordinates of the defect, wherein the gravity center extraction is performed after the feature point expansion of the second region, comprising: in the target first region, the row coordinate sum and the column coordinate sum of the second region of the target first region are determined; the gravity center row coordinate of the target first region is determined according to the row coordinate sum and the number of the second region of the target first region; the gravity center column coordinate of the target first region is determined according to the column coordinate sum and the number of the second region of the target first region.

2. The image processing based raw silk detection method as claimed in claim 1, wherein, The first region belonging to the background type is determined, comprising: The column standard deviation of each first region is determined; When the difference between the maximum value and the minimum value of the column standard deviation of the first region is greater than a first difference threshold, the first region belongs to the background type.

3. The image processing based raw silk detection method as claimed in claim 1, wherein, The feature point expansion of the second region comprises: The feature point expansion of the second region is performed 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.

4. The image processing based raw silk detection method as claimed in claim 1, wherein, Threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, further comprising: The maximum gray value and the minimum gray value of the first region are determined; If the difference between the maximum gray value and the minimum gray value of the first region is greater than a second difference threshold, the first region includes a plurality of second regions.

5. A raw silk detecting device based on image processing, characterized by The device is applied to the raw silk detection method based on image processing in any one of claims 1-4, and the device comprises: After obtaining the raw silk image, the raw silk image is converted into a gray image, and the raw silk image is cropped, wherein the slant line is retained in the cropped raw silk image; According to the preset requirement of cleanliness detection, the raw silk image is regionally divided to obtain a plurality of first regions, and each first region is of the same size; Threshold extraction and binarization are performed on the plurality of first regions to obtain a plurality of second regions, wherein the second region is related to the slant line and the second region is smaller than the first region; The second region is subjected to feature point expansion and barycenter extraction, to obtain the barycenter corresponding to each second region, and the coordinates of the barycenter are taken as the coordinates of the defect.

6. An electronic device, comprising: Comprise: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute to implement the image processing based raw silk detection method of any one of claims 1 to 4.

7. A non-transitory computer-readable storage medium, comprising: When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the image processing based raw silk detection method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Image background area detection method and device, storage medium and X-ray system

    CN110163857A

  • Raw silk defect detection method under non-uniform low-illumination condition

    CN117197058A