Free-form surface super photoscope defect detection model establishment method, system and equipment and medium
By establishing a defect detection environment on the free-form surface super-perspective mirror, performing grayscale and binarization processing, obtaining the screening area and using the real-time division mean to judge defects, the problem of halo and defect being difficult to distinguish is solved, and higher detection accuracy is achieved.
Patent Information
- Application Number
- CN202510835253.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-09-19
AI Technical Summary
Existing defect detection technology is prone to misjudgment on free-form surface super-mirrors due to the close proximity of halos and defects, making it difficult to accurately distinguish between halos and defects.
By establishing a defect detection environment, obtaining the lens image and grayscale processing, and obtaining the screening area after binarization processing, the presence of defects is judged based on the real-time division mean, and accurate identification is achieved by using the brightness difference between halo and defects.
The accuracy of defect recognition is improved, the phenomenon of halo being misjudged as defects is reduced, and the accuracy of detection is improved.
Smart Images

Figure CN120668688A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of defect detection technology, and specifically to a method, system, equipment and medium for establishing a free-form surface super-perspective mirror defect detection model. Background Art
[0002] Free-form surface meta-mirrors are increasingly being used in high-end imaging, virtual reality, augmented reality, and other fields due to their excellent optical performance and unique design. Their high light transmittance, complex asymmetric surfaces, and stringent surface quality requirements necessitate defect detection for curved meta-mirrors.
[0003] The free-form surface meta-mirror is a lens, so it needs to be illuminated during defect detection to make the defects visible. However, large-curvature lenses produce halos when illuminated, which interferes with defect detection. From the perspective of lens curvature, a qualitative analysis shows that as the curvature of the lens increases, the generation of light sources is inevitable. Ordinary lenses reduce the generation of halos as much as possible by adjusting the angle and size of the light source. The free-form surface meta-mirror has an unstable shape and an asymmetric surface, so it is difficult to adjust the light source to completely eliminate the halo. If a halo is generated at the same time as a defect, a bright area will be generated under lighting, so the halo is easily misjudged as a defect. That is, if the existing defect detection technology produces a halo, the halo and the defect are similar, resulting in incorrect defect detection. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems in the prior art to a certain extent by establishing a defect detection environment, obtaining a lens image based on the defect detection environment; gray-scaling the lens image to obtain a lens grayscale image; binarizing the lens grayscale image to obtain a lens binary image; obtaining a screening area based on the lens binary image; obtaining a real-time division mean based on the screening area; and judging whether a free-form surface meta-mirror has defects based on the real-time division mean, so as to solve the problem that if the existing defect detection technology produces a halo, the halo and the defect are similar, which leads to incorrect judgment of the defect detection.
[0005] To achieve the above objectives, the present application provides a method for establishing a free-form surface super-perspective mirror defect detection model, comprising the following steps:
[0006] Establishing a defect detection environment and obtaining a lens image based on the defect detection environment;
[0007] Performing grayscale processing on the lens image to obtain a lens grayscale image;
[0008] Binarizing the lens grayscale image to obtain a lens binarization image;
[0009] Obtaining the screening area based on the lens binarization image;
[0010] Get real-time partition mean based on the screening area;
[0011] Determine whether the free-form surface hyper-perspective mirror has defects based on the real-time division mean.
[0012] Furthermore, establishing a defect detection environment, and obtaining a lens image based on the defect detection environment includes the following sub-steps:
[0013] Set up a black background object, place the free-form surface hyperscope directly above the black background object, place a ring light around the free-form surface hyperscope, place a camera directly above the free-form surface hyperscope, and mark the image obtained by the camera as a lens diagram.
[0014] Furthermore, grayscale processing is performed on the lens image to obtain a lens grayscale image, which includes the following sub-steps:
[0015] Get the R value, G value and B value of each pixel in the lens image;
[0016] Calculate the average of the R value, G value, and B value of each pixel in the lens image, and mark it as the lens grayscale value;
[0017] Each pixel in the lens image is converted into a lens grayscale value to obtain a lens grayscale image.
[0018] Furthermore, binarizing the lens grayscale image to obtain a lens binarization image includes the following sub-steps:
[0019] Divide the grayscale value from 0 to 255 into k equal intervals, marked as partition intervals;
[0020] Count the frequency of lens grayscale values in each divided interval in the lens grayscale image respectively, and mark it as divided frequency;
[0021] Draw a histogram with the lens grayscale value as the X-axis, the divided frequency as the Y-axis, and the divided interval as the histogram interval, marked as the lens grayscale histogram;
[0022] In the lens grayscale histogram, the division intervals that are larger than the two adjacent division frequencies on the left and right sides are marked as peak intervals;
[0023] Obtain the number of peak intervals. If the number of peak intervals is less than 2, increase the specific value of k and rebuild the lens grayscale histogram until the number of peak intervals is greater than or equal to 2.
[0024] If the number of peak ranges is greater than or equal to 2, obtain the peak intervals, obtain the median of each peak interval, mark it as the peak median, obtain the peak interval with the smallest peak median, mark it as the first screening interval, obtain the peak interval with the largest peak median, mark it as the second screening interval;
[0025] Obtain the median value of the interval with the smallest frequency in the first screening interval and the second screening interval, and mark it as the screening threshold;
[0026] The grayscale values in the biological particle grayscale image that are greater than or equal to the screening threshold are set to 0, and the grayscale values in the biological particle grayscale image that are less than the screening threshold are set to 0 to obtain a lens binarization image.
[0027] Furthermore, obtaining the screening area based on the lens binarization image includes the following sub-steps:
[0028] Mark the pixels with grayscale value 0 in the lens binarization image as bright pixels;
[0029] Get any bright pixel point, mark it as the initial reference point, and establish a 3×3 pixel area with the initial reference point as the center, marked as the reference area;
[0030] Determine whether there is a new bright pixel in the reference area. If not, remove the initial reference point and select the next random bright pixel as the initial reference point. If yes,
[0031] A new reference area is established again with each new bright light pixel as the center pixel of the reference area, and the newly appeared bright light pixel is obtained from the new reference area. A new reference area is established again with each new bright light pixel as the center pixel of the reference area, and the acquisition of newly appeared bright light pixel and the establishment of the reference area are repeated until no new bright light pixel appears in the new reference area. The area of the bright light pixel obtained this time is marked as the screening area, and all the screening areas are obtained.
[0032] Furthermore, obtaining the real-time partition mean based on the screening area includes the following sub-steps:
[0033] Establish a plane rectangular coordinate system, marked as the comparison coordinate system, and place the lens binary image in the first quadrant, with the two sides of the lens binary image coinciding with the horizontal and vertical axes of the comparison coordinate system, respectively. Obtain the bright pixels adjacent to the pixels with a grayscale value of 255 in the screening area and mark them as black-edge pixels. Place the lens grayscale image in the comparison coordinate system, ensuring that the lens grayscale image and the lens binary image are placed in the same position. Obtain the pixels in the lens grayscale image corresponding to the black-edge pixels and mark them as boundary pixels.
[0034] Under all boundary pixels corresponding to a screening area, a 3×3 pixel area is established with the boundary pixel as the center, marked as the first partition area, and the bright light pixel points in the first partition area that are not boundary pixels are obtained and marked as the first partition pixel points. Then, a 3×3 pixel area is established with the first partition pixel as the center, marked as the second partition area, and the bright light pixel points in the second partition area that are not boundary pixels and the first partition pixel points are obtained and marked as the second partition pixel points. Then, a 3×3 pixel area is established with the second partition pixel as the center, marked as the third partition area, and the bright light pixel points in the third partition area that are not boundary pixels, the first partition pixel points, and the second partition pixel points are obtained and marked as the third partition pixel points. Repeat the acquisition until the nth partition pixel point;
[0035] The mean of the grayscale values of the first divided pixel to the nth divided pixel is marked as Xs. i ; Where i is an integer from 1 to n;
[0036] Calculate all Xs i+1 With Xs i The difference is marked as the partition difference;
[0037] Calculate the mean of all partition differences in a filter area and mark it as the real-time partition mean.
[0038] Furthermore, judging whether the free-form surface metallurgical mirror has defects based on the real-time partition mean includes the following sub-steps:
[0039] Obtaining a first number of images containing only halo portions, marking them as halo images, obtaining a screening area of the halo image, marking them as historical areas, and obtaining a real-time partitioning mean value based on each historical area, marking them as historical partitioning mean values;
[0040] Get the range of the historical partition mean, divide the range of the historical partition mean into f intervals, and mark them as historical intervals;
[0041] Count the frequency of each historical interval and mark it as the historical interval frequency;
[0042] Draw a histogram with the historical partition mean as the X-axis, the historical interval frequency as the Y-axis, and the historical interval as the histogram interval, marked as the partition histogram;
[0043] The image parts of the leftmost and rightmost parts of the partition histogram whose historical interval frequencies are less than the partition frequency threshold are obtained, and the minimum and maximum values of the horizontal coordinates of the deleted historical intervals in the partition histogram are marked as the first halo threshold and the second halo threshold respectively;
[0044] Determine whether the real-time division mean satisfies the conditions that are greater than or equal to the first halo threshold and less than or equal to the second halo threshold. If so, the corresponding screening area is identified as a halo area. If not, the screening area is identified as a defect area and a defect signal is issued.
[0045] The present application provides a free-form surface super-perspective mirror defect detection model establishment system, which includes an image acquisition module, a grayscale module, a binarization module, a region acquisition module, a mean acquisition module, and a defect judgment module;
[0046] The image acquisition module is used to establish a defect detection environment and acquire a lens image based on the defect detection environment;
[0047] The grayscale module is used to grayscale the lens image to obtain a lens grayscale image;
[0048] The binarization module is used to perform binarization processing on the lens grayscale image to obtain a lens binarization image;
[0049] The region acquisition module is used to acquire the screening region based on the lens binarization image;
[0050] The mean value acquisition module is used to obtain the real-time partition mean value based on the screening area;
[0051] The defect judgment module is used to judge whether the free-form surface super-perspective mirror has defects based on the real-time division mean.
[0052] The present application provides an electronic device, including a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the above method are performed.
[0053] The present application provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the above method are performed.
[0054] The beneficial effects of the present invention are as follows: the present invention establishes a defect detection environment, obtains a lens image based on the defect detection environment; grayscales the lens image to obtain a lens grayscale image; binarizes the lens grayscale image to obtain a lens binary image; obtains a screening area based on the lens binary image; obtains a real-time partitioning mean based on the screening area; and determines whether a free-form surface meta-mirror has defects based on the real-time partitioning mean. The advantage of the present invention is that the method can reduce the identification of halos as defects and improve the accuracy of defect identification.
[0055] The present invention obtains the real-time division mean based on the screening area. Its advantage is that the real-time division mean is set based on the distinction between halo and defect. The halo is brighter as it is closer to the center, while the defect refracts light at the boundary, so the light at the defect boundary is brighter. Therefore, the light source and the defect can be distinguished, thereby improving the accuracy of defect recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 is a functional block diagram of the system of the present invention;
[0057] Figure 2 is a schematic diagram of a lens grayscale histogram of the present invention;
[0058] Figure 3 is the amplitude scatter plot of the present invention;
[0059] Figure 4 A schematic diagram of a first divided area and a second divided area of the present invention;
[0060] Figure 5 Flow chart of the steps of the method of the present invention. DETAILED DESCRIPTION
[0061] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0062] Example 1, please refer to Figure 1 As shown, the present application provides a free-form surface super-perspective mirror defect detection model establishment system, including an image acquisition module, a grayscale module, a binarization module, a region acquisition module, a mean acquisition module and a defect judgment module;
[0063] The image acquisition module is used to establish a defect detection environment and acquire a lens image based on the defect detection environment;
[0064] The image acquisition module configures the image acquisition strategy, which includes:
[0065] Set up a black background object, place the free-form surface meta-mirror directly above the black background object, place a ring light around the free-form surface meta-mirror, place a camera directly above the free-form surface meta-mirror, and mark the image obtained by the camera as a lens image; establish a defect detection environment so that scratches will be displayed;
[0066] The grayscale module is used to grayscale the lens image to obtain a lens grayscale image;
[0067] The grayscale module is configured with a grayscale strategy, which includes:
[0068] Get the R value, G value and B value of each pixel in the lens image;
[0069] Obtain the average of the R value, G value, and B value of each pixel in the lens image, which is marked as the lens grayscale value; a grayscale conversion method;
[0070] Convert each pixel point in the lens image into a lens grayscale value to obtain a lens grayscale image;
[0071] In practical applications, for example, if the R value, G value, and B value of a pixel in the lens image are 200, 198, and 212 respectively, then the lens grayscale value is (200+198+212) / 3=203, and the calculation result is rounded to an integer.
[0072] The binarization module is used to perform binarization processing on the lens grayscale image to obtain a lens binarization image;
[0073] The binarization module is configured with a binarization strategy, which includes:
[0074] Divide the grayscale value from 0 to 255 into k equal intervals, marked as divided intervals. Divide the intervals to obtain the distribution of the lens grayscale value, so the setting of k cannot be too small. However, if k is set too large, the calculation amount will increase. Therefore, k is set to 8, which can distinguish the distribution of grayscale values without excessive calculation amount.
[0075] Count the frequency of lens grayscale values in each divided interval in the lens grayscale image respectively, and mark it as divided frequency;
[0076] Draw a histogram with the lens grayscale value as the X-axis, the divided frequency as the Y-axis, and the divided interval as the histogram interval, marked as the lens grayscale histogram;
[0077] In the lens grayscale histogram, the division intervals that are larger than the two adjacent division frequencies on the left and right sides are marked as peak intervals;
[0078] Obtain the number of peak intervals. If the number of peak intervals is less than 2, increase the specific value of k and rebuild the lens grayscale histogram until the number of peak intervals is greater than or equal to 2. Because the background is black and the spots and defects are bright white, this detection image is a prerequisite for the presence of defects or halos, so two peaks will appear.
[0079] If the number of peak ranges is greater than or equal to 2, obtain the peak intervals, obtain the median of each peak interval, mark it as the peak median, obtain the peak interval with the smallest peak median, mark it as the first screening interval, obtain the peak interval with the largest peak median, mark it as the second screening interval;
[0080] Obtain the median value of the interval with the smallest frequency in the first screening interval and the second screening interval, and mark it as the screening threshold;
[0081] The grayscale values in the biological particle grayscale image that are greater than or equal to the screening threshold are set to 0, and the grayscale values in the biological particle grayscale image that are less than the screening threshold are set to 0, to obtain a lens binary image;
[0082] In practical applications, please refer to Figure 2 As shown, the first screening interval obtained is 0 to 31, the second screening threshold is 223 to 255, the division interval with the smallest division frequency between 0 to 31 and 223 to 255 is 127 to 159, and the median is 143. Therefore, the screening threshold is 143, and the grayscale values greater than or equal to 143 in the biological particle grayscale image are set to 0, and the grayscale values less than 143 in the biological particle grayscale image are set to 0 to obtain a lens binarization image.
[0083] The region acquisition module is used to obtain the screening region based on the lens binarization image;
[0084] The region acquisition module is configured with a region acquisition strategy, which includes:
[0085] Mark the pixels with grayscale value 0 in the lens binarization image as bright pixels;
[0086] Get any bright pixel point, mark it as the initial reference point, and establish a 3×3 pixel area with the initial reference point as the center, marked as the reference area;
[0087] Determine whether there are new bright light pixels in the reference area. If not, remove the initial reference point and continue to select the next arbitrary bright light pixel as the initial reference point; if yes, use the new bright light pixel as the center pixel of the reference area to establish a new reference area again, obtain the newly appeared bright light pixel from the new reference area, and use the newly appeared bright light pixel as the center pixel of the reference area to establish a new reference area again, repeat obtaining the newly appeared bright light pixel and establishing the reference area until there are no new bright light pixels in the new reference area, mark the area of the bright light pixel obtained this time as the screening area, and obtain all the screening areas; set the screening area to obtain the pixel position of the individual bright area, and at the same time filter out the individual interference pixels.
[0088] The mean acquisition module is used to obtain the real-time partition mean based on the screening area;
[0089] The mean acquisition module is configured with a mean acquisition strategy, which includes:
[0090] Establish a plane rectangular coordinate system, marked as the contrast coordinate system, and place the lens binary image in the first quadrant, with the two sides of the lens binary image coinciding with the horizontal and vertical axes of the contrast coordinate system respectively; obtain the bright pixel points adjacent to the pixel point with a grayscale value of 255 in the screening area and mark them as black-edge pixels; place the lens grayscale image in the contrast coordinate system, while ensuring that the lens grayscale image and the lens binary image are placed in the same position, obtain the pixel points corresponding to the black-edge pixel point position in the lens grayscale image and mark them as boundary pixels; obtain the boundary pixels of each bright area for the lens grayscale image;
[0091] Under all the boundary pixels corresponding to a screening area, a 3×3 pixel area is established with the boundary pixel as the center, marked as the first divided area, and the bright light pixel points in the first divided area that are not boundary pixels are obtained, marked as the first divided pixel points. Then a 3×3 pixel area is established with the first divided pixel as the center, marked as the second divided area, and the bright light pixel points in the second divided area that are not boundary pixels and the first divided pixel points are obtained, marked as the second divided pixel points. Then a 3×3 pixel area is established with the second divided pixel as the center, marked as the third divided area, and the bright light pixel points in the third divided area that are not boundary pixels and the first divided pixel points are obtained. The bright pixel points of the pixel point and the second divided pixel point are marked as the third divided pixel point, and the acquisition is repeated until the nth divided pixel point; because the halo is brighter as it approaches the center, and the defect boundary light is brighter, and because the free-form surface meta-perspective mirror is an irregular shape, the distance from the boundary is acquired and it is better to divide it into regular objects. Therefore, by setting the grayscale value of the first divided pixel point to the nth divided pixel point, the change of the grayscale value of the first divided pixel point to the nth divided pixel point is used to judge whether it is a defect or a halo; n is based on the setting of the halo size. The n setting is generally the maximum value that can be divided. At the same time, for the convenience of unification and calculation, it should not be set too large, for example, it is set to 8;
[0092] The mean of the grayscale values of the first divided pixel to the nth divided pixel is marked as Xs. i ; Where i is an integer from 1 to n;
[0093] Calculate all Xs i+1 With Xs i The difference is marked as the partition difference;
[0094] Calculate the mean of all partition differences in a screening area and mark it as the real-time partition mean;
[0095] In practical applications, please refer to Figure 3As shown, the obtained first partition pixel point and the second partition pixel point, for example, Xs1 to Xs3 are: 143, 146, 148, 150, 153, 157, 162 and 170 respectively; the partition differences are 3, 2, 2, 2, 3, 4 and 8 respectively, and the average of all partition differences in a screening area is 3.4, and the calculation result is rounded to one decimal place.
[0096] The defect judgment module is used to judge whether the free-form surface super-perspective mirror has defects based on the real-time partition mean;
[0097] The defect judgment module is configured with a defect judgment strategy, which includes:
[0098] Obtain a first number of images containing only halo portions, marked as halo images; obtain a filtered area of the halo image, marked as a historical area; and obtain a real-time partition mean value of each historical area, marked as a historical partition mean; wherein the first number of halo images obtains a distribution range of the historical partition mean values, so the first number should not be too low, for example, set to 130;
[0099] Obtain the range of the historical partition mean, divide the range of the historical partition mean into f intervals, and mark them as historical intervals. In order to obtain the historical partition mean and filter out errors, f must be set to be greater than or equal to 3, for example, f is set to 6.
[0100] Count the frequency of each historical interval and mark it as the historical interval frequency;
[0101] Draw a histogram with the historical partition mean as the X-axis, the historical interval frequency as the Y-axis, and the historical interval as the histogram interval, marked as the partition histogram;
[0102] The image portion of the historical interval frequency that is less than the division frequency threshold on the far left and far right of the division histogram is obtained, and the minimum and maximum values of the horizontal coordinates of the historical interval after the division histogram are deleted are marked as the first halo threshold and the second halo threshold respectively; the division frequency threshold is set based on the setting of the first number and f, and it is usually considered that one tenth of the proportion is small. When the first number is 130 and f is 6, the division frequency threshold is: 130 / 6×0.1=2.1;
[0103] Determine whether the real-time segmentation mean satisfies a condition greater than or equal to a first halo threshold and less than or equal to a second halo threshold. If so, identify the corresponding screening area as a halo area. If not, identify the screening area as a defect area and issue a defect signal.
[0104] In practical applications, please refer to Figure 4As shown in the partition histogram, the frequency of the historical interval from 2 to 3 is 2, and the frequency of the historical interval from 7 to 8 is 1. Therefore, if they are deleted from the partition histogram, the first halo threshold and the second halo threshold are 3 to 7 respectively; the real-time partition mean of 3.4 satisfies the conditions of being greater than or equal to 3 and less than or equal to 7, so the corresponding screening area is identified as a halo area, and no defect signal is issued.
[0105] Example 2, please refer to Figure 5 As shown, the present application provides a method for establishing a free-form surface super-perspective mirror defect detection model, comprising the following steps:
[0106] Step S1: Establish a defect detection environment and obtain a lens image based on the defect detection environment. Step S1 includes the following sub-steps:
[0107] Step S101: Set a black background object, place the free-form surface meta-mirror directly above the black background object, place a ring light around the free-form surface meta-mirror, place a camera directly above the free-form surface meta-mirror, and mark the image obtained by the camera as a lens image.
[0108] Step S2, grayscale processing is performed on the lens image to obtain a lens grayscale image; Step S2 includes the following sub-steps:
[0109] Step S201, obtaining the R value, G value, and B value of each pixel in the lens image;
[0110] Step S202, obtaining the average of the R value, G value, and B value of each pixel in the lens image, and marking it as the lens grayscale value;
[0111] Step S203: Convert each pixel in the lens image into a lens grayscale value to obtain a lens grayscale image.
[0112] Step S3, binarizing the lens grayscale image to obtain a lens binarization image; Step S3 includes the following sub-steps:
[0113] Step S301, divide the grayscale value from 0 to 255 into k equal intervals, marked as divided intervals;
[0114] Step S303, counting the frequency of the lens grayscale value in each divided interval in the lens grayscale image, and marking it as the divided frequency;
[0115] Step S304: draw a histogram with the lens grayscale value as the X-axis, the divided frequency as the Y-axis, and the divided interval as the histogram interval, and mark it as the lens grayscale histogram;
[0116] Step S305: In the lens grayscale histogram, mark the division intervals that are respectively larger than the two adjacent division frequencies on the left and right sides as peak intervals;
[0117] Step S306, obtaining the number of peak intervals. If the number of peak intervals is less than 2, increasing the specific value of k and re-establishing the lens grayscale histogram until the number of peak intervals is greater than or equal to 2;
[0118] Step S307: If the number of peak ranges is greater than or equal to 2, obtain peak intervals, obtain the median of each peak interval and mark it as the peak median, obtain the peak interval with the smallest peak median and mark it as the first screening interval, obtain the peak interval with the largest peak median and mark it as the second screening interval;
[0119] Step S308: Obtain the median value of the interval with the smallest frequency in the first screening interval and the second screening interval, and mark it as the screening threshold;
[0120] Step S309 , setting the grayscale values in the biological particle grayscale image that are greater than or equal to the screening threshold to 0, and setting the grayscale values in the biological particle grayscale image that are less than the screening threshold to 0, to obtain a lens binary image.
[0121] Step S4, obtaining a screening area based on the lens binarization image; Step S4 includes the following sub-steps:
[0122] Step S401, marking pixels with a grayscale value of 0 in the lens binarization image as bright pixels;
[0123] Step S402: Obtain any bright pixel point, mark it as an initial reference point, and establish a 3×3 pixel area with the initial reference point as the center, marked as a reference area;
[0124] Step S403, determine whether there are new bright light pixels in the reference area. If not, remove the initial reference point and continue to select the next arbitrary bright light pixel as the initial reference point. If yes, establish a new reference area again with the new bright light pixel as the center pixel of the reference area, obtain the newly appeared bright light pixel from the new reference area, and establish a new reference area again with the newly appeared bright light pixel as the center pixel of the reference area. Repeat the process of obtaining the newly appeared bright light pixel and establishing the reference area until there are no new bright light pixels in the new reference area. Mark the area of the bright light pixel obtained this time as the screening area, and obtain all the screening areas.
[0125] Step S5, obtaining a real-time partition mean based on the screening area; Step S5 includes the following sub-steps:
[0126] Step S501: Establish a plane rectangular coordinate system, labeled as the comparison coordinate system, and place the lens binary image in the first quadrant, with the two sides of the lens binary image coinciding with the horizontal and vertical axes of the comparison coordinate system, respectively. Obtain bright pixels adjacent to pixels with a grayscale value of 255 in the screening area and label them as black-edge pixels. Place the lens grayscale image in the comparison coordinate system, ensuring that the lens grayscale image and the lens binary image are placed in the same position. Obtain pixels in the lens grayscale image corresponding to the black-edge pixels and label them as boundary pixels.
[0127] Step S502: Under all boundary pixels corresponding to a screening area, a 3×3 pixel area is established with the boundary pixel as the center, marked as the first partition area, and bright light pixels in the first partition area that are not boundary pixels are obtained and marked as the first partition pixels. Then, a 3×3 pixel area is established with the first partition pixel as the center, marked as the second partition area, and bright light pixels in the second partition area that are not boundary pixels and the first partition pixel are obtained and marked as the second partition pixels. Then, a 3×3 pixel area is established with the second partition pixel as the center, marked as the third partition area, and bright light pixels in the third partition area that are not boundary pixels, the first partition pixel, or the second partition pixel are obtained and marked as the third partition pixel. This process is repeated until the nth partition pixel.
[0128] Step S503: mark the mean of the grayscale values of the first divided pixel to the mean of the grayscale values of the nth divided pixel as Xs i ; Where i is an integer from 1 to n;
[0129] Step S504, calculate all Xs i+1 With Xs i The difference is marked as the partition difference;
[0130] Step S505 , obtaining the mean of all partition differences within a screening area, and marking it as the real-time partition mean.
[0131] Step S6, judging whether the free-form surface metallurgical mirror has defects based on the real-time segmentation mean; Step S6 includes the following sub-steps:
[0132] Obtaining a first number of images containing only halo portions, marking them as halo images, obtaining a screening area of the halo image, marking them as historical areas, and obtaining a real-time partitioning mean value based on each historical area, marking them as historical partitioning mean values;
[0133] Get the range of the historical partition mean, divide the range of the historical partition mean into f intervals, and mark them as historical intervals;
[0134] Count the frequency of each historical interval and mark it as the historical interval frequency;
[0135] Draw a histogram with the historical partition mean as the X-axis, the historical interval frequency as the Y-axis, and the historical interval as the histogram interval, marked as the partition histogram;
[0136] The image parts of the leftmost and rightmost parts of the partition histogram whose historical interval frequencies are less than the partition frequency threshold are obtained, and the minimum and maximum values of the horizontal coordinates of the deleted historical intervals in the partition histogram are marked as the first halo threshold and the second halo threshold respectively;
[0137] Determine whether the real-time division mean satisfies the conditions that are greater than or equal to the first halo threshold and less than or equal to the second halo threshold. If so, the corresponding screening area is identified as a halo area. If not, the screening area is identified as a defect area and a defect signal is issued.
[0138] In a third embodiment, the present application further provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus. The memory stores computer-readable instructions, and the processor may call the instructions in the memory. When the computer-readable instructions are executed by the processor, the processor executes the steps in a method for establishing a free-form surface metallurgical mirror defect detection model to implement the following functions: establishing a defect detection environment, obtaining a lens image based on the defect detection environment; gray-scaling the lens image to obtain a lens grayscale image; binarizing the lens grayscale image to obtain a lens binary image; obtaining a screening area based on the lens binary image; obtaining a real-time partition mean based on the screening area; and determining whether the free-form surface metallurgical mirror has defects based on the real-time partition mean.
[0139] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program code.
[0140] Example 4. The present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute a method for establishing a free-form surface super-perspective mirror defect detection model provided by the above methods. The method includes: establishing a defect detection environment, and obtaining a lens image based on the defect detection environment; graying the lens image to obtain a lens grayscale image; binarizing the lens grayscale image to obtain a lens binarization image; obtaining a screening area based on the lens binarization image; obtaining a real-time partition mean based on the screening area; and judging whether the free-form surface super-perspective mirror has defects based on the real-time partition mean.
[0141] Example 5. The present application also provides a computer-readable storage medium. The present application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method for establishing a free-form surface super-perspective mirror defect detection model are executed to achieve the following functions: establish a defect detection environment, and obtain a lens image based on the defect detection environment; grayscale the lens image to obtain a lens grayscale image; binarize the lens grayscale image to obtain a lens binarization image; obtain a screening area based on the lens binarization image; obtain a real-time division mean based on the screening area; and judge whether the free-form surface super-perspective mirror has defects based on the real-time division mean.
[0142] Through the description of the above embodiments, the embodiments of the present invention can be provided as methods, systems, or computer program products. Based on this understanding, the essence of the above technical solutions or the portion that contributes to the prior art can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for enabling a computer device (such as a personal computer, server, or network device) to execute the methods described in various embodiments or certain portions of the embodiments.
[0143] In the embodiments provided in this application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of systems, modules and units can be electrical, mechanical or other forms.
[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for establishing a free-form surface super-perspective mirror defect detection model, characterized in that: The steps include: Establishing a defect detection environment and obtaining a lens image based on the defect detection environment; Performing grayscale processing on the lens image to obtain a lens grayscale image; Binarizing the lens grayscale image to obtain a lens binarization image; Obtaining the screening area based on the lens binarization image; Get real-time partition mean based on the screening area; Determine whether the free-form surface hyper-perspective mirror has defects based on the real-time division mean.
2. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 1, characterized in that: Establishing a defect detection environment and obtaining a lens image based on the defect detection environment includes the following sub-steps: Set up a black background object, place the free-form surface hyperscope directly above the black background object, place a ring light around the free-form surface hyperscope, place a camera directly above the free-form surface hyperscope, and mark the image obtained by the camera as a lens diagram.
3. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 2, characterized in that: Grayscale processing of the lens image to obtain the lens grayscale image includes the following sub-steps: Get the R value, G value and B value of each pixel in the lens image; Calculate the average of the R value, G value, and B value of each pixel in the lens image, and mark it as the lens grayscale value; Each pixel in the lens image is converted into a lens grayscale value to obtain a lens grayscale image.
4. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 3, characterized in that: Binarizing the lens grayscale image to obtain a lens binary image includes the following sub-steps: Divide the grayscale value from 0 to 255 into k equal intervals, marked as partition intervals; Count the frequency of lens grayscale values in each divided interval in the lens grayscale image respectively, and mark it as divided frequency; Draw a histogram with the lens grayscale value as the X-axis, the divided frequency as the Y-axis, and the divided interval as the histogram interval, marked as the lens grayscale histogram; In the lens grayscale histogram, the division intervals that are larger than the two adjacent division frequencies on the left and right sides are marked as peak intervals; Obtain the number of peak intervals. If the number of peak intervals is less than 2, increase the specific value of k and rebuild the lens grayscale histogram until the number of peak intervals is greater than or equal to 2. If the number of peak ranges is greater than or equal to 2, obtain the peak intervals, obtain the median of each peak interval, mark it as the peak median, obtain the peak interval with the smallest peak median, mark it as the first screening interval, obtain the peak interval with the largest peak median, mark it as the second screening interval; Obtain the median value of the interval with the smallest frequency in the first screening interval and the second screening interval, and mark it as the screening threshold; The grayscale values in the biological particle grayscale image that are greater than or equal to the screening threshold are set to 0, and the grayscale values in the biological particle grayscale image that are less than the screening threshold are set to 0 to obtain a lens binarization image.
5. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 4, characterized in that: Obtaining the screening area based on the lens binarization image includes the following sub-steps: Mark the pixels with grayscale value 0 in the lens binarization image as bright pixels; Get any bright pixel point, mark it as the initial reference point, and establish a 3×3 pixel area with the initial reference point as the center, marked as the reference area; Determine whether there are new bright light pixels in the reference area. If not, remove the initial reference point and select the next arbitrary bright light pixel as the initial reference point. If yes, use the new bright light pixel as the center pixel of the reference area to establish a new reference area again, obtain the newly appeared bright light pixel from the new reference area, and use the newly appeared bright light pixel as the center pixel of the reference area to establish a new reference area again. Repeat obtaining the newly appeared bright light pixel and establishing the reference area until there are no new bright light pixels in the new reference area. Mark the area of the bright light pixel obtained this time as the screening area, and obtain all the screening areas.
6. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 5, characterized in that: Obtaining the real-time partition mean based on the screening area includes the following sub-steps: Establish a plane rectangular coordinate system, marked as the comparison coordinate system, and place the lens binary image in the first quadrant, while the two sides of the lens binary image coincide with the horizontal axis and vertical axis of the comparison coordinate system respectively; Obtain the bright pixels adjacent to the pixels with a grayscale value of 255 in the screening area and mark them as black-edge pixels. Place the lens grayscale image in the comparison coordinate system, ensuring that the lens grayscale image and the lens binary image are placed in the same position. Obtain the pixels corresponding to the black-edge pixel positions in the lens grayscale image and mark them as boundary pixels. Under all boundary pixels corresponding to a screening area, a 3×3 pixel area is established with the boundary pixel as the center, marked as the first partition area, and the bright light pixel points in the first partition area that are not boundary pixels are obtained and marked as the first partition pixel points. Then, a 3×3 pixel area is established with the first partition pixel as the center, marked as the second partition area, and the bright light pixel points in the second partition area that are not boundary pixels and the first partition pixel points are obtained and marked as the second partition pixel points. Then, a 3×3 pixel area is established with the second partition pixel as the center, marked as the third partition area, and the bright light pixel points in the third partition area that are not boundary pixels, the first partition pixel points, and the second partition pixel points are obtained and marked as the third partition pixel points. Repeat the acquisition until the nth partition pixel point; The mean of the grayscale values of the first divided pixel to the nth divided pixel is marked as Xs. i ; Where i is an integer from 1 to n; Calculate all Xs i+1 With Xs i The difference is marked as the partition difference; Calculate the mean of all partition differences in a filter area and mark it as the real-time partition mean.
7. The method for establishing a free-form surface super-perspective mirror defect detection model according to claim 6, characterized in that: Determining whether a free-form surface super-perspective mirror has defects based on the real-time partition mean includes the following sub-steps: Obtaining a first number of images containing only halo portions, marking them as halo images, obtaining a screening area of the halo image, marking them as historical areas, and obtaining a real-time partitioning mean value based on each historical area, marking them as historical partitioning mean values; Get the range of the historical partition mean, divide the range of the historical partition mean into f intervals, and mark them as historical intervals; Count the frequency of each historical interval and mark it as the historical interval frequency; Draw a histogram with the historical partition mean as the X-axis, the historical interval frequency as the Y-axis, and the historical interval as the histogram interval, marked as the partition histogram; The image parts of the leftmost and rightmost parts of the partition histogram whose historical interval frequencies are less than the partition frequency threshold are obtained, and the minimum and maximum values of the horizontal coordinates of the deleted historical intervals in the partition histogram are marked as the first halo threshold and the second halo threshold respectively; Determine whether the real-time division mean satisfies the conditions that are greater than or equal to the first halo threshold and less than or equal to the second halo threshold. If so, the corresponding screening area is identified as a halo area. If not, the screening area is identified as a defect area and a defect signal is issued.
8. A free-form surface super-perspective mirror defect detection model establishment system, adapted to the free-form surface super-perspective mirror defect detection model establishment method according to any one of claims 1 to 7, characterized in that: It includes image acquisition module, grayscale module, binarization module, region acquisition module, mean acquisition module and defect judgment module; The image acquisition module is used to establish a defect detection environment and acquire a lens image based on the defect detection environment; The grayscale module is used to grayscale the lens image to obtain a lens grayscale image; The binarization module is used to perform binarization processing on the lens grayscale image to obtain a lens binarization image; The region acquisition module is used to acquire the screening region based on the lens binarization image; The mean value acquisition module is used to obtain the real-time partition mean value based on the screening area; The defect judgment module is used to judge whether the free-form surface super-perspective mirror has defects based on the real-time division mean.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 7 are executed.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are executed.