Disclosure of Invention
The invention provides a light-emitting diode illumination quality detection method based on image processing, which aims to solve the problem that the existing light-emitting diode illumination quality detection method is different in different scene measurement standards, and adopts the following technical scheme:
one embodiment of the present invention provides a method for detecting illumination quality of a light emitting diode based on image processing, comprising the steps of:
acquiring an illumination gray image of a light emitting diode and an illumination quality to-be-measured area, and calculating a color rendering index, an initial luminous flux and an initial luminous efficiency of the light emitting diode;
Dividing an illumination quality to-be-measured area into a first area and a second area according to gray values, acquiring energy values and gray average values of the first area and the second area, acquiring a minimum circumscribed matrix and an illumination side of the illumination quality to-be-measured area, and calculating the distance from each pixel point in the first area and the second area to the illumination side as a first distance and a second distance; obtaining the illumination uniformity of the illumination quality to-be-detected area according to the energy value and the gray average value of the first area, the average value of all the first distances, the energy value and the gray average value of the second area and the average value of all the second distances;
Dividing the minimum circumscribed rectangle into a first part and a second part according to the midpoint of the illumination side in the minimum circumscribed matrix of the illumination quality to-be-detected area and the midpoint of the minimum circumscribed matrix, acquiring all edge pixel points in the minimum circumscribed rectangle, acquiring the distance from each edge point to the side of the minimum circumscribed matrix in each part according to the part where the edge point is positioned, marking the pixel points according to the distance, and acquiring the minimum observation angle according to all the marked pixel points;
Obtaining a growth threshold according to gray values of all pixel points of an illumination quality to-be-detected area, dividing the illumination quality to-be-detected area into a plurality of third areas according to the growth threshold, obtaining edge pixel points of each third area, and judging according to the edge pixel points of each third area and a minimum observation angle to obtain a plurality of fourth areas;
Obtaining illumination comprehensive quality according to the fourth area number, the third area number, illumination uniformity of an illumination quality to-be-detected area, a minimum observation angle, a color rendering index of the light emitting diode, initial luminous flux and initial luminous efficiency;
and acquiring the illumination comprehensive quality of a plurality of directions, selecting the average value of the two largest illumination comprehensive qualities as the final value of the illumination comprehensive quality, and judging the quality of the light emitting diode according to the final value of the illumination comprehensive quality.
Preferably, the method for obtaining the minimum circumscribed matrix and the illumination side of the illumination quality to-be-measured area and calculating the distance from each pixel point in the first area and the second area to the illumination side as the first distance and the second distance includes:
The method comprises the steps of obtaining a minimum external matrix of an illumination quality to-be-detected area, marking one side, close to a light source, of the minimum external matrix as an illumination side, calculating Euclidean distances between each pixel point of a first area and all pixel points on the illumination side, wherein the minimum distance is a first distance between the pixel point and the illumination side, and the second area is the same, and calculating Euclidean distances between each pixel point and all pixel points on the illumination side, wherein the minimum distance is a second distance between the pixel point and the illumination side.
Preferably, the method for obtaining the illumination uniformity of the illumination quality to-be-measured area according to the energy value and the gray average value of the first area, the average value of all the first distances, the energy value and the gray average value of the second area, and the average value of all the second distances comprises the following steps:
Wherein asm1 represents the energy value of the first region, asm2 represents the energy value of the second region, exp () is an exponential function based on a natural constant, x1 is the gray average value of the first region, x2 is the gray average value of the second region, di1 is the distance sequence of the first region, n1 is the number of pixels of the first region, di2 is the distance sequence of the second region, n2 is the number of pixels of the second region, and u represents the illumination uniformity of the illumination quality to-be-measured region.
Preferably, the method for dividing the illumination quality to be measured into a plurality of third areas according to the growth threshold, obtaining edge pixel points of each third area, and obtaining a plurality of fourth areas by judging according to the edge pixel points of each third area and the minimum observation angle includes:
Acquiring gray values of all pixel points with the gray value of 1% of the to-be-measured area of the illumination quality, and acquiring a growth threshold according to the maximum value and the minimum value of the pixel points to acquire a plurality of third areas;
and obtaining edge pixel points of each third region, detecting the edge pixel points of each third region by using Hough circles, traversing all the edge pixel points to obtain a circle with highest voting weight, reducing the circle threshold value according to the ratio of the minimum observation angle to the circle, and considering the third region as a fourth region when the voting number is larger than the circle threshold value, thereby converting all the third regions into a plurality of fourth regions.
Preferably, the method for obtaining the illumination comprehensive quality according to the fourth area number, the third area number, the illumination uniformity of the illumination quality to-be-measured area, the minimum observation angle, the color rendering index of the light emitting diode, the initial luminous flux and the initial light efficiency comprises the following steps:
Wherein b 1,b2,b3 is a constant coefficient, and the empirical values are 0.4,1,0.6 respectively; c, d, e are the ratio of the color rendering index, the initial luminous flux and the initial luminous efficiency measured by the light emitting diode to the maximum total value of the light emitting diode respectively; m1 is the number of areas after the areas are grown, m2 is the number of circles detected, u represents the illumination uniformity, and α represents the minimum viewing angle.
The beneficial effects of the invention are as follows: the method comprises the steps of evaluating the uniformity of the brightness of light emitted by a light emitting diode from the characteristic that the light of the light emitting diode points to a smaller range, comprehensively integrating the whole area (the existing sampling points represent the uniformity of the whole light) related to the light in the evaluation process, acquiring the range with better uniformity as the minimum observation angle, and simultaneously, comprehensively evaluating the illumination quality by combining other aspects of the light emitting diode, and providing more accurate basis for the specific application scene of the light emitting diode on the premise of ensuring accurate judgment.
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.
Referring to fig. 1, a flowchart of a method for detecting illumination quality of a light emitting diode based on image processing according to an embodiment of the invention is shown, the method includes the following steps:
step S001, acquiring an image of the light emitting diode and various related data of which the illumination quality needs to be detected.
The light emitting diode is mainly round, square and special-shaped, and the detection of the illumination quality of the light emitting diode by the scheme is to analyze the specific condition of a light column generated on the side surface of the light emitting diode, so that the shape of the light emitting diode and the illumination quality analysis of the light emitting diode are not influenced. However, the beads of the light emitting diode are horizontally arranged, one side is left and the other side is right, namely, two sides emit light, so that the measurement result is more accurate, images are respectively obtained from four different sides of the light emitting diode, each side is spaced by 90 degrees, and a top view schematic diagram is shown in fig. 2. The final analysis result is judged by the result of two sides of the four sides, which can better shoot the illumination condition.
The light emitting diode is placed in a dark chamber, a CCD camera is arranged according to the description, the lighting condition of the light emitting diode is shot after the light emitting diode is electrified, the obtained image is recorded as a diode lighting image, and the diode lighting image is an RGB image.
Noise inevitably occurs on the obtained diode illumination image due to the influence of factors such as environment, vibration of internal parts of a camera and the like, and in order to avoid the influence of the existence of the noise on the result of subsequent analysis, gaussian filtering is used for convolution with each channel of the diode illumination image to denoise the image, so that the accuracy and quality of the image are improved. The gaussian filtering denoising is a well-known technique, and the specific process is not repeated.
The floating point algorithm is used to convert the diode illumination image into a gray scale image, which is noted as the diode illumination gray scale image. The maximum inter-class variance method is used to obtain a divided threshold value for the diode illumination gray scale image, and the image can be divided into two parts according to the threshold value. The illuminated part after the light emitting diode emits light is the part needing to analyze the illumination quality, and the corresponding gray value of the part in the image is larger, so that the area, in which the gray value is larger than the threshold value (namely the divided threshold value obtained above), in the image is selected and is recorded as the illumination quality to-be-detected area.
And detecting the light-emitting diode by using an integrating sphere to obtain a corresponding color rendering index, an initial luminous flux and an initial light effect. The use of an integrating sphere to obtain the above-mentioned index is a well-known technique, and the specific process is not described in detail.
And S002, analyzing the characteristics of light uniformity, observation angle and the like during illumination, and obtaining the comprehensive evaluation of the illumination quality of the diode.
The incandescent lamp emits light to the periphery of the lamp, no matter which direction the incandescent lamp stands in, the emitted light can be seen, in comparison, the light emitted by the light emitting diode is mainly directed to a certain direction, namely a smaller range, which determines the minimum observation angle of the light generated by the light emitting diode after the light emitting diode is electrified. When the light angle of the light emitting diode is larger, the minimum observation angle is larger, and the application range is wider.
The light-emitting diode has uniform brightness, consistent color and no obvious dark area. The brightness gradually decreases as the distance traveled by the emitted light increases, but the same position as the distance of the light source exhibits uniform brightness.
The illumination quality measurement area is divided into two parts according to a threshold value obtained by using a maximum inter-class variance method. And (3) marking the area corresponding to the pixel points with the gray values larger than the threshold value in the illumination quality to-be-detected area as a first area, and marking the area formed by other pixel points as a second area.
When the light-emitting diode has good quality, the brightness of the light emitted by the light-emitting diode at the same position from the light source is consistent, the two divided areas respectively correspond to a brighter part which is closer to the light source and a part which is farther from the light source and has slightly weakened brightness, the brightness difference between the two parts is smaller, and the gray scales in the areas are uniform and have smaller change. When the illumination quality of the led is poor, an obvious dark area appears, and the two divided areas correspond to the part with brighter illumination and the dark area respectively, which is usually caused by that one of the two beads of the led does not normally emit light. Based on this, analysis was performed.
All pixel points of the illumination quality to-be-detected area are classified into 10 grades, and the grading method comprises the following steps:
Where H i is the gray value of the ith pixel, S i is the gray value of the ith pixel, and int () is a rounding function.
And for the illumination quality to-be-detected area with the classified levels, the gray level co-occurrence matrix of the area obtained by all the pixel points of the first area is recorded as a first matrix, the gray level co-occurrence matrix of the area obtained by all the pixel points of the second area is recorded as a second matrix, and the energy values asm1 and asm2 of the first matrix and the second matrix are obtained, wherein the energy reflects the uniform distribution degree of the gray level values in the area, and the more uniform the energy is, the smaller the energy is. When the light emitting diode has good quality, the energy values corresponding to the two areas are smaller and the difference is smaller.
And when the respective gray average value of the first region and the second region is x1 and x2, and the quality of the light-emitting diode is good, the difference of the gray average values corresponding to the two regions is smaller.
And acquiring the minimum circumscribed rectangle of the illumination quality to-be-detected area, and marking the edge closest to the light emitting diode in the rectangle as an illumination side. The Euclidean distance between each pixel point in the first area and each pixel point on the illumination side is obtained, the minimum value in the distances is recorded as the distance between the pixel point and the illumination side, and the distance between each pixel point in the first area and the illumination side is respectively recorded as d 1,d2,…,dn1. Similarly, the distance between each pixel point and the illumination side in the second region is denoted as D 1,D2,…,Dn2. When the light emitting diode has good quality, the distance between the pixel point in the first area and the illumination side is obviously smaller than the distance between the pixel point in the second area and the illumination side. When the illumination quality of the light-emitting diode is poor, the dark areas are distributed on one of the left side and the right side of the illumination light, and the distances between the pixel points and the illumination sides in the two areas are not obviously different.
Because the uniformity of illumination reflects the uniformity of light emitted by the light emitting diode during illumination, a darker light source is generated on one side according to poor illumination quality, and the illumination uniformity u is constructed according to the above index, wherein the illumination uniformity u is analyzed according to the characteristic that the illumination is gradually weakened along with the increase of illumination distance when the illumination quality is good, and the illumination is slightly reduced at a far distance, when the difference between the two parts of illumination divided according to the difference of the illumination is smaller and the difference between the two parts of illumination and the illumination is more obvious, the formula is as follows:
Wherein asm1 represents the energy value of the first region, asm2 represents the energy value of the second region, exp () is an exponential function based on a natural constant, x1 is the gray average value of the first region, x2 is the gray average value of the second region, di1 is the distance sequence of the first region, n1 is the number of pixels of the first region, di2 is the distance sequence of the second region, n2 is the number of pixels of the second region, and u represents the illumination uniformity of the illumination quality to-be-measured region.
All edge points of an illumination quality to-be-detected area are obtained through Canny operator detection, the edge of a rectangle corresponding to the illumination side of the minimum circumscribed rectangle of the illumination quality to-be-detected area and the opposite edge of the rectangle are taken, the midpoints of the two edges are respectively taken, a line segment is obtained by connecting the two midpoints, the illumination quality to-be-detected area is divided into two parts by the line segment, and the edge of the illumination quality to-be-detected area is also divided into two parts. Each portion was analyzed separately.
Two edges connected with the illumination measurement in the smallest circumscribed rectangle of the illumination quality measurement area are marked as side edges. Taking each vertical distance between each pixel point on each part edge and the corresponding side edge of the edge, taking the shorter distance of the front t2 in the vertical distances, taking t2 as a value range coefficient, taking an empirical value as 60%, and marking the point on the edge corresponding to the obtained distance. The two parts divided into by the edge of the illumination quality measured area are marked according to the steps.
And respectively fitting the pixel points marked according to the process in each part with straight lines by using a least square method to obtain two fitting straight lines, wherein the two straight lines are considered as boundaries of light emitted by the light emitting diode when the light emitting diode is used for illumination. The angle between these two straight lines is denoted as the minimum viewing angle and α.
When the light emitting diode is powered on, the larger the minimum observation angle of the generated light is, the wider the application range of the light emitting diode is, namely the better the illumination quality is.
The gray value corresponding to each pixel point in the to-be-measured area of the illumination quality is taken, the pixel point with the gray value t3 before is taken, the pixel points are the part of the light rays which are displayed when the illumination is performed and are closest to the light source, t3 is a value range coefficient, and the empirical value is 1%. The maximum and minimum values of these gray values are noted as g 1,g2, respectively. Threshold value recordingA1 is a constant coefficient, and the empirical value is 10; int () is a rounding function.
And (3) carrying out region growth on the illumination quality to-be-detected region according to a threshold t4 to obtain m1 regions after the growth is completed.
When light is scattered outward from the light source, the brightness appearing in the image decreases slowly as the distance gets farther, but should be uniform when the same distance as the light source is focused. Therefore, all the areas obtained through the area growth in the process are distributed in the area to be measured of the illumination quality in a circular ring shape.
Marking pixel points corresponding to the edges of each region obtained by region growth in a region to be detected of illumination quality, detecting the edge points of each region by using Hough circle, modifying voting weight by combining the Hough circle detection with a minimum observation angle alpha, and detecting the whole circle by using a conventional Hough circle, wherein only in the schemeThe circles are detected, thus multiplying the detection threshold byThe number of circles detected is noted as m2. When the detected number of edge points is larger than the proportion of the number of the areas obtained by the area growth, the circular distribution characteristics of the areas divided according to the brightness are more obvious, namely, the brightness of the light rays in the same distance from the light source is more consistent, and the illumination quality of the light emitting diode is better.
The illumination comprehensive quality reflects the comprehensive illumination quality of the light-emitting diode, evaluates the consistency of the brightness of the light rays of the light-emitting diode at the same distance, the overall uniformity of the illumination brightness and the minimum observation angle, and the illumination quality reflected by other related indexes of the light-emitting diode, and constructs the illumination comprehensive quality q:
Wherein b 1,b2,b3 is a constant coefficient, and the empirical values are 0.4,1,0.6 respectively; c, d, e are the ratio of the color rendering index, the initial luminous flux and the initial luminous efficiency measured by the light emitting diode to the maximum total value of the light emitting diode respectively; m1 is the number of areas after the areas are grown, m2 is the number of circles detected, u represents the illumination uniformity, and α represents the minimum viewing angle.
And step S003, comprehensively judging the illumination quality of the light emitting diode according to the illumination comprehensive quality of the four directions.
And obtaining the illumination comprehensive quality corresponding to the images obtained by the four different sides of the light-emitting diode according to the steps, and taking the larger two values as the illumination quality evaluation results corresponding to the two sides of the illumination condition which are better shot. Taking the average value of the two values as the final value of the illumination comprehensive quality of the light-emitting diode, and when the value is greater than or equal to t5, considering that the illumination quality of the light-emitting diode is excellent, wherein t5 is a value range coefficient, and the empirical value is 1, so that the LED can be used in places needing accurate color comparison judgment; when the value is greater than or equal to t6 and less than t5, the illumination quality of the light-emitting diode is considered to be general, t6 is a value range coefficient, and the empirical value is 0.75, so that the light-emitting diode can be used in places with lower requirements on the color rendering; when the value is smaller than t6, the light emitting diode is considered to have poor illumination quality, and can be used only in places where color rendering is not particularly required.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.