Disclosure of Invention
The invention aims to overcome the defects of the prior art, and provides a high-magnification light source uniformity detection method and system, which can better judge whether a currently projected high-magnification light source reaches a required uniformity standard.
In order to solve the technical problems, the invention provides a high-magnification light source uniformity detection method, which comprises the following steps:
Acquiring a facula image projected to a target plane by a high-magnification light source device according to a set target light source, and preprocessing the facula image to acquire a preprocessed facula image;
Dividing the preprocessed facula image to obtain a facula image after dividing;
Determining illumination intensity and illumination area of the segmented facula image, and calculating a first light source uniformity coefficient of a target light source of the high-magnification light source device based on the illumination intensity and the illumination area;
acquiring a corresponding gray distribution curve based on the segmented light spot image, and determining a light spot gray parameter based on the gray distribution curve;
Calculating a second light source uniformity coefficient based on the light spot gray scale parameters and the calibration parameters, and calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient;
and determining whether the light source uniformity of the high-magnification light source device reaches a preset standard or not based on the target light source uniformity coefficient.
Optionally, the preprocessing the spot image to obtain a preprocessed spot image includes:
carrying out graying treatment on the facula image to obtain a graying facula image;
denoising the graying facula image to obtain a denoised graying facula image;
And performing image enhancement processing on the denoised gray facula image to obtain a preprocessed facula image.
Optionally, the splitting processing is performed on the preprocessed spot image to obtain a split processed spot image, which includes:
setting an image pixel neighborhood for the preprocessed facula image, and calculating a gray average value and an image entropy value of the image pixel neighborhood;
extracting color characteristic components of the preprocessed facula images to obtain target color characteristic components;
Setting a segmentation threshold based on the target color feature component, a gray average value, and an image entropy value;
And dividing the preprocessed facula image by using an adaptive threshold dividing algorithm based on the dividing threshold to obtain a divided facula image.
Optionally, the determining the illumination intensity and the illumination area of the segmented light spot image includes:
bit layering is carried out on the segmented facula image, and a facula image after bit layering is obtained;
calculating the statistic value of the target pixel point in the facula image after bit layering, and calculating the illumination intensity based on the statistic value of the target pixel point;
and carrying out pixel-level classification on the segmented facula image to obtain an illumination area.
Optionally, the calculating the first light source uniformity coefficient of the target light source of the high-magnification light source device based on the illumination intensity and the illumination area includes:
inputting the illumination intensity and the illumination area into a feedforward neural network to perform brightness distribution analysis, and obtaining a brightness distribution analysis result;
A first light source uniformity coefficient of a target light source of the high-magnification light source device is calculated based on the luminance distribution analysis result.
Optionally, the acquiring a corresponding gray distribution curve based on the segmented light spot image, and determining the light spot gray parameter based on the gray distribution curve, includes:
setting a plurality of rectangular frames, and determining gray values of edge images of the segmented facula images based on the rectangular frames;
Generating a corresponding gray level distribution curve based on the gray level value, and generating a facula gray level histogram based on the gray level distribution curve;
and calculating a slope parameter of the light spot gray level histogram, and determining the light spot gray level parameter based on the slope parameter.
Optionally, the calculating the second light source uniformity coefficient based on the light spot gray scale parameter and the calibration parameter includes:
Calculating a spot centroid based on the illumination intensity and the illumination area, and calculating spot area brightness based on the spot centroid;
Generating a calibration matrix by using a preset gray matrix based on the calibration parameters;
And calculating a second light source uniformity coefficient based on the light spot area brightness and the light spot gray scale parameter and combining the calibration matrix.
Optionally, the calculating the target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient includes:
Acquiring weight coefficients corresponding to the first light source uniformity coefficient and the second light source uniformity coefficient;
And calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient in combination with the corresponding weight coefficient.
Optionally, the determining whether the light source uniformity of the high-magnification light source device reaches a preset standard based on the target light source uniformity coefficient includes:
calculating a target difference value between the target light source uniformity coefficient and the standard light source uniformity coefficient;
judging whether the target difference value is within a preset allowable range, and if the target difference value is within the preset allowable range, judging that the light source uniformity of the high-magnification light source equipment reaches a preset standard;
if the target difference value is not within the preset allowable range, judging that the light source uniformity of the high-magnification light source equipment does not reach the preset standard.
In addition, the invention also provides a high-magnification light source uniformity detection system, which comprises:
the spot image preprocessing module is used for acquiring a spot image projected to a target plane by the high-magnification light source equipment according to the set target light source, preprocessing the spot image and acquiring a preprocessed spot image;
The image segmentation module is used for carrying out segmentation processing on the preprocessed facula image to obtain a facula image after segmentation processing;
the first light source uniformity coefficient calculation module is used for determining illumination intensity and illumination area of the segmented facula image and calculating a first light source uniformity coefficient of a target light source of the high-magnification light source device based on the illumination intensity and the illumination area;
the light spot gray scale parameter module is used for acquiring a corresponding gray scale distribution curve based on the light spot image after the segmentation processing and determining light spot gray scale parameters based on the gray scale distribution curve;
The target light source uniformity coefficient calculation module is used for calculating a second light source uniformity coefficient based on the light spot gray scale parameter and the calibration parameter, and calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient;
the light source uniformity judging module is used for determining whether the light source uniformity of the high-magnification light source device reaches a preset standard or not based on the target light source uniformity coefficient.
In the embodiment of the invention, the segmentation threshold is set according to the target color characteristic component, the gray average value and the image entropy value obtained by the preprocessed facula image so as to segment the facula image, thereby improving the precision of image segmentation and the efficiency of subsequent image analysis. The first light source uniformity coefficient of the target light source of the high-magnification light source device is calculated based on the illumination intensity and the illumination area, so that the intensity uniformity of the light source range can be clarified. The corresponding gray distribution curve is obtained according to the segmented light spot image so as to determine the gray parameters of the light spot, the second light source uniformity coefficient is calculated according to the gray parameters of the light spot and the calibration parameters, and the target light source uniformity coefficient is calculated based on the first light source uniformity coefficient and the second light source uniformity coefficient, so that the obtained target light source uniformity coefficient is more fit with the actual situation, the uniformity and the limitation caused by uniformity detection of a single light source uniformity coefficient are avoided, the uniformity of the high-magnification light source can be reflected more accurately, and whether the currently projected high-magnification light source reaches the required uniformity standard is judged better.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1, fig. 1 is a flow chart of a high-magnification light source uniformity detection method according to an embodiment of the invention, the method includes:
S11, acquiring a facula image projected to a target plane by high-magnification light source equipment according to a set target light source, and preprocessing the facula image to obtain a preprocessed facula image;
In the implementation process of the invention, the preprocessing of the facula image to obtain a preprocessed facula image comprises the steps of carrying out graying processing on the facula image to obtain a graying facula image, carrying out denoising processing on the graying facula image to obtain a graying facula image after denoising processing, and carrying out image enhancement processing on the graying facula image after denoising processing to obtain a preprocessed facula image.
Specifically, the high-magnification light source device may be a light source device applied to a microscope device, the high-magnification light source device is set by using a light source parameter commonly used in the microscope device as a target light source, the set high-magnification light source device performs spot projection on a target plane, and the image pickup device collects a spot image on the target plane. And carrying out graying treatment on the spot image, and carrying out arithmetic average on the numerical values of the three primary color components of the pixel points in the spot image to obtain the gray value of the pixel points so as to graying the spot image and obtain the graying spot image. And denoising the graying facula image, namely randomly selecting a pixel point in the graying facula image, taking the pixel point as a central point, acquiring a neighborhood of the central point, sequencing gray values of all the pixel points in the neighborhood, taking the middle value as a new value of the gray of the central pixel, and filtering the graying facula image by using a preset window according to the new value to obtain the denoised graying facula image. And carrying out image enhancement processing on the denoised graying facula image, wherein the image enhancement processing comprises image edge enhancement and image pixel spatial filtering, and after the image enhancement processing is finished, the preprocessed facula image can be obtained.
S12, dividing the preprocessed facula image to obtain a facula image after dividing;
in the specific implementation process of the invention, the segmentation processing is carried out on the preprocessed spot image to obtain the segmented spot image, and the segmentation processing comprises the steps of setting an image pixel neighborhood for the preprocessed spot image, calculating the gray average value and the image entropy value of the image pixel neighborhood, extracting color characteristic components of the preprocessed spot image to obtain target color characteristic components, setting a segmentation threshold value based on the target color characteristic components, the gray average value and the image entropy value, and carrying out the segmentation processing on the preprocessed spot image by utilizing an adaptive threshold value segmentation algorithm based on the segmentation threshold value to obtain the segmented spot image.
Specifically, an image pixel neighborhood is set for the preprocessed facula image, a gray average value and an image entropy value of the image pixel neighborhood are calculated, the gray average value is calculated according to the gray values of all pixels in the image pixel neighborhood, and the image entropy value of the image pixel neighborhood is calculated according to a calculation formula of the entropy value. Extracting color characteristic components of the preprocessed spot images, carrying out average value calculation on all pixels in the preprocessed spot images to obtain target average values, generating pixel matrixes according to the target average values, calculating color vector angle matrixes and color Euclidean distance matrixes of the pixel matrixes, obtaining first transverse and longitudinal change matrixes of the color vector angle matrixes and second transverse and longitudinal change matrixes of the color Euclidean distance matrixes, forming target color characteristic components according to the first transverse and longitudinal change matrixes and the second transverse and longitudinal change matrixes, and obtaining more comprehensive color characteristic components. And setting a segmentation threshold value based on the target color characteristic component, the gray average value and the image entropy value, and determining the segmentation threshold value according to the proportion of the target color characteristic component, the gray average value and the image entropy value to the target color characteristic component, the gray average value and the image entropy value. And dividing the preprocessed spot image by using an adaptive threshold dividing algorithm based on the dividing threshold, comparing each pixel in the preprocessed spot image with the dividing threshold, dividing the preprocessed spot image into a target area if the pixel value is greater than or equal to the dividing threshold, and dividing the preprocessed spot image into a background area if the pixel value is less than the dividing threshold, so as to divide the preprocessed spot image and obtain the divided spot image.
S13, determining illumination intensity and illumination area of the segmented facula image, and calculating a first light source uniformity coefficient of a target light source of the high-magnification light source device based on the illumination intensity and the illumination area;
In the specific implementation process of the invention, the method for determining the illumination intensity and the illumination area of the segmented light spot image comprises the steps of carrying out bit layering on the segmented light spot image to obtain the bit layered light spot image, calculating the statistic value of a target pixel point in the bit layered light spot image, calculating the illumination intensity based on the statistic value of the target pixel point, and carrying out pixel level classification on the segmented light spot image to obtain the illumination area.
Further, the calculating of the first light source uniformity coefficient of the target light source of the high-magnification light source device based on the illumination intensity and the illumination area comprises the steps of inputting the illumination intensity and the illumination area into a feedforward neural network to perform brightness distribution analysis to obtain a brightness distribution analysis result, and calculating the first light source uniformity coefficient of the target light source of the high-magnification light source device based on the brightness distribution analysis result.
Specifically, bit layering is carried out on the facula image after the segmentation processing, a preset number of bit layers with the lowest layer number are selected as low bit layers, namely, the pixel value of the image is split into different binary bit planes, each bit plane contains bit information of corresponding pixels in the image, the gray value of the pixel point of each bit layer is only set to 0 and 255, and the facula image after the bit layering is obtained. Calculating the statistic value of the target pixel point in the spot image after bit layering, namely counting the number of the pixel points with the pixel value of 255 in the spot image after bit layering, namely calculating the illumination intensity based on the statistic value of the target pixel point, and calculating the illumination intensity by a preset illumination intensity calculation formula through the statistic value of the target pixel point. And carrying out pixel-level classification on the segmented light spot images, carrying out feature extraction on the segmented light spot images to obtain feature images, carrying out linear interpolation processing on the feature images to obtain the feature images after the linear interpolation processing, carrying out pixel class label distribution on the feature images after the linear interpolation processing by using a softmax function to obtain a light source contour, and calculating the illumination area according to pixel points in the light source contour. And inputting the illumination intensity and the illumination area into a feedforward neural network for brightness distribution analysis, wherein the feedforward neural network consists of a plurality of layers of computing units, the computing units are connected with each other in a feedforward mode, and each neural unit in each layer of computing units is directly connected with a neural unit in the next layer to obtain a brightness distribution analysis result. And calculating a first light source uniformity coefficient of the target light source of the high-magnification light source device based on the brightness distribution analysis result, and knowing the brightness distribution of each light source region according to the brightness distribution analysis result, so that the first light source uniformity coefficient of the target light source of the high-magnification light source device can be determined.
S14, acquiring a corresponding gray distribution curve based on the segmented light spot image, and determining a light spot gray parameter based on the gray distribution curve;
in the implementation process of the invention, the method for acquiring the corresponding gray distribution curve based on the segmented light spot image and determining the light spot gray parameter based on the gray distribution curve comprises the steps of setting a plurality of rectangular frames, determining the gray value of the edge image of the segmented light spot image based on the rectangular frames, generating the corresponding gray distribution curve based on the gray value, generating the light spot gray histogram based on the gray distribution curve, calculating the slope parameter of the light spot gray histogram, and determining the light spot gray parameter based on the slope parameter.
Specifically, a plurality of rectangular frames are set, the sizes of the rectangular frames are consistent, gray values of edge images of the segmented facula images are determined based on the rectangular frames, the edge images are determined according to the obtained light source contours, and gray values of corresponding areas are obtained in the edge images by the rectangular frames. And generating a corresponding gray level distribution curve based on the gray level values, drawing the distribution curve according to the gray level values of each area acquired by each rectangular frame, obtaining a corresponding gray level distribution curve, generating a facula gray level histogram based on the gray level distribution curve, and generating the facula gray level histogram by using the gray level distribution curve through a cv2.CalcHist () function. And calculating a slope parameter of the light spot gray level histogram, namely calculating the slope of gray level distribution in the light spot gray level histogram, reflecting the change trend of gray level frequency, and determining the light spot gray level parameter based on the slope parameter.
S15, calculating a second light source uniformity coefficient based on the light spot gray scale parameter and the calibration parameter, and calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient;
In the implementation process of the invention, the calculation of the second light source uniformity coefficient based on the light spot gray scale parameter and the calibration parameter comprises the steps of calculating the light spot centroid based on the illumination intensity and the illumination area, calculating the light spot area brightness based on the light spot centroid, generating a calibration matrix by utilizing a preset gray matrix based on the calibration parameter, and calculating the second light source uniformity coefficient based on the light spot area brightness and the light spot gray scale parameter and the calibration matrix.
Further, the calculating the target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient comprises obtaining weight coefficients corresponding to the first light source uniformity coefficient and the second light source uniformity coefficient, and calculating the target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient and combining the corresponding weight coefficients.
Specifically, a spot centroid is calculated based on the illumination intensity and the illumination area, coordinate values of each pixel in the segmented spot image on an X axis and a Y axis are obtained, a communication area is marked according to the coordinate values and the illumination intensity, the center of gravity of the spot image is calculated according to an illumination area calculation target light source, the spot centroid is calculated according to the marked communication area and the center by using a geometric distance algorithm, spot area brightness is calculated based on the spot centroid, a plurality of annular areas are selected by taking the spot centroid as the center of a circle, and brightness parameters of each annular area are calculated, namely the spot area brightness is calculated. Generating a calibration matrix by using a preset gray matrix based on the calibration parameters, acquiring a matrix consistent with the pixel number of the calibration image, namely, the calibration parameters, setting standard gray values, setting all data in the matrix consistent with the pixel number of the calibration image as the standard gray values, generating a standard matrix, generating the calibration matrix according to the standard matrix and the preset gray matrix, and effectively correcting the deviation of the brightness of the facula area and the gray parameter of the facula through the calibration matrix. And calculating a second light source uniformity coefficient based on the light spot area brightness and the light spot gray scale parameter and combining the calibration matrix, so that the obtained second light source uniformity coefficient is more accurate. And acquiring weight coefficients corresponding to the first light source uniformity coefficient and the second light source uniformity coefficient, wherein different light source uniformity coefficients correspond to different weight coefficients, and the corresponding weight coefficients can be matched in a database. And calculating a target light source uniformity coefficient based on the combination of the first light source uniformity coefficient and the second light source uniformity coefficient and the corresponding weight coefficient, so that the one-sided property and the limitation brought by the uniformity coefficient of the single light source can be avoided, and the obtained target light source uniformity coefficient is more fit with the actual situation.
S16, determining whether the light source uniformity of the high-magnification light source device reaches a preset standard or not based on the target light source uniformity coefficient.
In the implementation process of the invention, the method for determining whether the light source uniformity of the high-magnification light source device reaches the preset standard based on the target light source uniformity coefficient comprises the steps of calculating a target difference value between the target light source uniformity coefficient and the standard light source uniformity coefficient, judging whether the target difference value is within a preset allowable range, judging that the light source uniformity of the high-magnification light source device reaches the preset standard if the target difference value is within the preset allowable range, and judging that the light source uniformity of the high-magnification light source device does not reach the preset standard if the target difference value is not within the preset allowable range.
Specifically, a target difference value between the target light source uniformity coefficient and a standard light source uniformity coefficient is calculated, wherein the standard light source uniformity coefficient is a standard value of high-magnification light source uniformity obtained through a large number of experiments. Judging whether the target difference value is within a preset allowable range, if the target difference value is within the preset allowable range, judging that the uniformity of the light source of the high-magnification light source device reaches a preset standard, and judging the uniformity level of the target light source projected by the high-magnification light source device according to the target difference value, wherein different target difference values correspond to different uniformity levels. If the target difference value is not within the preset allowable range, judging that the light source uniformity of the high-magnification light source equipment does not reach the preset standard.
In the embodiment of the invention, the segmentation threshold is set according to the target color characteristic component, the gray average value and the image entropy value obtained by the preprocessed facula image so as to segment the facula image, thereby improving the precision of image segmentation and the efficiency of subsequent image analysis. The first light source uniformity coefficient of the target light source of the high-magnification light source device is calculated based on the illumination intensity and the illumination area, so that the intensity uniformity of the light source range can be clarified. The corresponding gray distribution curve is obtained according to the segmented light spot image so as to determine the gray parameters of the light spot, the second light source uniformity coefficient is calculated according to the gray parameters of the light spot and the calibration parameters, and the target light source uniformity coefficient is calculated based on the first light source uniformity coefficient and the second light source uniformity coefficient, so that the obtained target light source uniformity coefficient is more fit with the actual situation, the uniformity and the limitation caused by uniformity detection of a single light source uniformity coefficient are avoided, the uniformity of the high-magnification light source can be reflected more accurately, and whether the currently projected high-magnification light source reaches the required uniformity standard is judged better.
Example two
Referring to fig. 2, fig. 2 is a flow chart of a high-magnification light source uniformity detection method according to another embodiment of the invention, the method includes:
s201, acquiring a facula image projected to a target plane by high-magnification light source equipment according to a set target light source, and preprocessing the facula image to obtain a preprocessed facula image;
In the implementation process of the invention, the high-magnification light source device can be a light source device applied to the microscope device, the high-magnification light source device is set by taking the light source parameters commonly used in the microscope device as a target light source, the set high-magnification light source device performs light spot projection on a target plane, and the camera device acquires light spot images on the target plane. And carrying out graying treatment on the spot image, and carrying out arithmetic average on the numerical values of the three primary color components of the pixel points in the spot image to obtain the gray value of the pixel points so as to graying the spot image and obtain the graying spot image. And denoising the graying facula image, namely randomly selecting a pixel point in the graying facula image, taking the pixel point as a central point, acquiring a neighborhood of the central point, sequencing gray values of all the pixel points in the neighborhood, taking the middle value as a new value of the gray of the central pixel, and filtering the graying facula image by using a preset window according to the new value to obtain the denoised graying facula image. And carrying out image enhancement processing on the denoised graying facula image, wherein the image enhancement processing comprises image edge enhancement and image pixel spatial filtering, and after the image enhancement processing is finished, the preprocessed facula image can be obtained.
S202, setting an image pixel neighborhood for the preprocessed facula image, and calculating a gray average value and an image entropy value of the image pixel neighborhood;
in the specific implementation process of the invention, an image pixel neighborhood is set for the preprocessed facula image, the gray average value and the image entropy of the image pixel neighborhood are calculated, the gray average value is calculated according to the gray value of each pixel in the image pixel neighborhood, and the image entropy of the image pixel neighborhood is calculated according to the calculation formula of the entropy.
S203, extracting color characteristic components of the preprocessed facula images to obtain target color characteristic components;
In the specific implementation process of the invention, color characteristic components of the preprocessed spot images are extracted, average value calculation is carried out on all pixels in the preprocessed spot images to obtain a target average value, a pixel matrix is generated according to the target average value, a color vector angle matrix and a color Euclidean distance matrix of the pixel matrix are calculated, a first transverse and longitudinal change matrix and a second transverse and longitudinal change matrix of the color vector angle matrix are obtained, a target color characteristic component is formed according to the first transverse and longitudinal change matrix and the second transverse and longitudinal change matrix, and more comprehensive color characteristic components can be obtained.
S204, setting a segmentation threshold value based on the target color feature component, the gray average value and the image entropy value;
In the implementation process of the invention, the segmentation threshold is set based on the target color characteristic component, the gray average value and the image entropy value, and the segmentation threshold is determined according to the target color characteristic component, the gray average value and the image entropy value and the corresponding proportion.
S205, dividing the preprocessed facula image by using an adaptive threshold dividing algorithm based on the dividing threshold to obtain a divided facula image;
In the specific implementation process of the invention, the segmentation processing is carried out on the preprocessed facula image by utilizing the self-adaptive threshold segmentation algorithm based on the segmentation threshold, each pixel in the preprocessed facula image is compared with the segmentation threshold, if the pixel value is larger than or equal to the segmentation threshold, the pixel value is divided into a target area, and if the pixel value is smaller than the segmentation threshold, the pixel value is divided into a background area, so that the preprocessed facula image is segmented, and the segmented facula image is obtained.
S206, determining illumination intensity and illumination area of the segmented facula image, and calculating a first light source uniformity coefficient of a target light source of the high-magnification light source device based on the illumination intensity and the illumination area;
in the specific implementation process of the invention, bit layering is carried out on the facula image after the segmentation processing, a preset number of bit layers with the lowest layer number are selected as low bit layers, namely, the pixel value of the image is split into different binary bit planes, each bit plane contains bit information of corresponding pixels in the image, the gray value of the pixel point of each bit layer is only set to 0 and 255, and the facula image after the bit layering is obtained. Calculating the statistic value of the target pixel point in the spot image after bit layering, namely counting the number of the pixel points with the pixel value of 255 in the spot image after bit layering, namely calculating the illumination intensity based on the statistic value of the target pixel point, and calculating the illumination intensity by a preset illumination intensity calculation formula through the statistic value of the target pixel point. And carrying out pixel-level classification on the segmented light spot images, carrying out feature extraction on the segmented light spot images to obtain feature images, carrying out linear interpolation processing on the feature images to obtain the feature images after the linear interpolation processing, carrying out pixel class label distribution on the feature images after the linear interpolation processing by using a softmax function to obtain a light source contour, and calculating the illumination area according to pixel points in the light source contour. And inputting the illumination intensity and the illumination area into a feedforward neural network for brightness distribution analysis, wherein the feedforward neural network consists of a plurality of layers of computing units, the computing units are connected with each other in a feedforward mode, and each neural unit in each layer of computing units is directly connected with a neural unit in the next layer to obtain a brightness distribution analysis result. And calculating a first light source uniformity coefficient of the target light source of the high-magnification light source device based on the brightness distribution analysis result, and knowing the brightness distribution of each light source region according to the brightness distribution analysis result, so that the first light source uniformity coefficient of the target light source of the high-magnification light source device can be determined.
S207, acquiring a corresponding gray distribution curve based on the segmented light spot image, and determining a light spot gray parameter based on the gray distribution curve;
In the implementation process of the invention, a plurality of rectangular frames are arranged, the sizes of the rectangular frames are consistent, the gray value of the edge image of the facula image after the segmentation processing is determined based on the rectangular frames, the edge image is determined according to the acquired light source contour, and each rectangular frame acquires the gray value of the corresponding area in the edge image. And generating a corresponding gray level distribution curve based on the gray level values, drawing the distribution curve according to the gray level values of each area acquired by each rectangular frame, obtaining a corresponding gray level distribution curve, generating a facula gray level histogram based on the gray level distribution curve, and generating the facula gray level histogram by using the gray level distribution curve through a cv2.CalcHist () function. And calculating a slope parameter of the light spot gray level histogram, namely calculating the slope of gray level distribution in the light spot gray level histogram, reflecting the change trend of gray level frequency, and determining the light spot gray level parameter based on the slope parameter.
S208, calculating a spot centroid based on the illumination intensity and the illumination area, and calculating spot area brightness based on the spot centroid;
in the specific implementation process of the invention, the spot centroid is calculated based on the illumination intensity and the illumination area, coordinate values of each pixel in the segmented spot image on the X axis and the Y axis are obtained, the communication area is marked according to the coordinate values and the illumination intensity, the center of gravity of the spot image is calculated according to the illumination area calculation target light source, the spot centroid is calculated according to the marked communication area and the center by utilizing a geometric distance algorithm, the spot area brightness is calculated based on the spot centroid, a plurality of annular areas are selected by taking the spot centroid as the circle center, and the brightness parameter of each annular area is calculated, namely the spot area brightness is calculated. Generating a calibration matrix by using a preset gray matrix based on the calibration parameters, acquiring a matrix consistent with the pixel number of the calibration image, namely, the calibration parameters, setting standard gray values, setting all data in the matrix consistent with the pixel number of the calibration image as the standard gray values, generating a standard matrix, generating the calibration matrix according to the standard matrix and the preset gray matrix, and effectively correcting the deviation of the brightness of the facula area and the gray parameter of the facula through the calibration matrix.
S209, calculating a second light source uniformity coefficient based on the light spot area brightness and the light spot gray scale parameter and combining the calibration matrix, and calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient;
In the implementation process of the invention, the second light source uniformity coefficient is calculated based on the light spot area brightness and the light spot gray scale parameter and combined with the calibration matrix, so that the obtained second light source uniformity coefficient is more accurate. And acquiring weight coefficients corresponding to the first light source uniformity coefficient and the second light source uniformity coefficient, wherein different light source uniformity coefficients correspond to different weight coefficients, and the corresponding weight coefficients can be matched in a database. And calculating a target light source uniformity coefficient based on the combination of the first light source uniformity coefficient and the second light source uniformity coefficient and the corresponding weight coefficient, so that the one-sided property and the limitation brought by the uniformity coefficient of the single light source can be avoided, and the obtained target light source uniformity coefficient is more fit with the actual situation.
S210, determining whether the light source uniformity of the high-magnification light source device reaches a preset standard or not based on the target light source uniformity coefficient.
In the specific implementation process of the invention, the target difference value of the target light source uniformity coefficient and the standard light source uniformity coefficient is calculated, wherein the standard light source uniformity coefficient is a standard value of high-magnification light source uniformity obtained through a large number of experiments. Judging whether the target difference value is within a preset allowable range, if the target difference value is within the preset allowable range, judging that the uniformity of the light source of the high-magnification light source device reaches a preset standard, and judging the uniformity level of the target light source projected by the high-magnification light source device according to the target difference value, wherein different target difference values correspond to different uniformity levels. If the target difference value is not within the preset allowable range, judging that the light source uniformity of the high-magnification light source equipment does not reach the preset standard.
In the embodiment of the invention, the segmentation threshold is set according to the target color characteristic component, the gray average value and the image entropy value obtained by the preprocessed facula image so as to segment the facula image, thereby improving the precision of image segmentation and the efficiency of subsequent image analysis. The first light source uniformity coefficient of the target light source of the high-magnification light source device is calculated based on the illumination intensity and the illumination area, so that the intensity uniformity of the light source range can be clarified. The corresponding gray distribution curve is obtained according to the segmented light spot image so as to determine the gray parameters of the light spot, the second light source uniformity coefficient is calculated according to the gray parameters of the light spot and the calibration parameters, and the target light source uniformity coefficient is calculated based on the first light source uniformity coefficient and the second light source uniformity coefficient, so that the obtained target light source uniformity coefficient is more fit with the actual situation, the uniformity and the limitation caused by uniformity detection of a single light source uniformity coefficient are avoided, the uniformity of the high-magnification light source can be reflected more accurately, and whether the currently projected high-magnification light source reaches the required uniformity standard is judged better.
Example III
Referring to fig. 3, fig. 3 is a schematic structural diagram of a high-magnification light source uniformity detection system according to an embodiment of the present invention, the system includes:
The spot image preprocessing module 31 is used for acquiring a spot image projected to a target plane by the high-magnification light source equipment according to the set target light source, preprocessing the spot image and acquiring a preprocessed spot image;
The image segmentation module 32 is used for carrying out segmentation processing on the preprocessed facula image to obtain a facula image after segmentation processing;
A first light source uniformity coefficient calculation module 33 for determining illumination intensity and illumination area of the segmented flare image, and calculating a first light source uniformity coefficient of a target light source of the high-magnification light source device based on the illumination intensity and illumination area;
The light spot gray scale parameter module 34 is used for acquiring a corresponding gray scale distribution curve based on the light spot image after the segmentation processing and determining a light spot gray scale parameter based on the gray scale distribution curve;
the target light source uniformity coefficient calculation module 35 is used for calculating a second light source uniformity coefficient based on the light spot gray scale parameter and the calibration parameter, and calculating a target light source uniformity coefficient based on the first light source uniformity coefficient and the second light source uniformity coefficient;
The light source uniformity judging module 36 is used for determining whether the light source uniformity of the high-magnification light source device reaches a preset standard or not based on the target light source uniformity coefficient.
In the implementation process of the present invention, the specific embodiments of the system item may refer to the embodiments of the method item described above, which are not described herein again.
In the embodiment of the invention, the segmentation threshold is set according to the target color characteristic component, the gray average value and the image entropy value obtained by the preprocessed facula image so as to segment the facula image, thereby improving the precision of image segmentation and the efficiency of subsequent image analysis. The first light source uniformity coefficient of the target light source of the high-magnification light source device is calculated based on the illumination intensity and the illumination area, so that the intensity uniformity of the light source range can be clarified. The corresponding gray distribution curve is obtained according to the segmented light spot image so as to determine the gray parameters of the light spot, the second light source uniformity coefficient is calculated according to the gray parameters of the light spot and the calibration parameters, and the target light source uniformity coefficient is calculated based on the first light source uniformity coefficient and the second light source uniformity coefficient, so that the obtained target light source uniformity coefficient is more fit with the actual situation, the uniformity and the limitation caused by uniformity detection of a single light source uniformity coefficient are avoided, the uniformity of the high-magnification light source can be reflected more accurately, and whether the currently projected high-magnification light source reaches the required uniformity standard is judged better.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be implemented by a program for instructing related hardware, and the program may be stored in a computer readable storage medium, and the storage medium may include a Read Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk or an optical disk, etc.
In addition, the foregoing describes the method and system for detecting uniformity of a high-magnification light source according to the embodiments of the present invention in detail, and specific examples should be adopted to illustrate the principles and embodiments of the present invention, and the description of the foregoing examples is only for aiding in understanding the method and core concept of the present invention, and meanwhile, for those skilled in the art, according to the concept of the present invention, there are variations in the specific embodiments and application ranges, so the disclosure should not be construed as limiting the present invention.