CN117274405A - LED lamp working color detection method based on machine vision - Google Patents

LED lamp working color detection method based on machine vision Download PDF

Info

Publication number
CN117274405A
CN117274405A CN202311558387.8A CN202311558387A CN117274405A CN 117274405 A CN117274405 A CN 117274405A CN 202311558387 A CN202311558387 A CN 202311558387A CN 117274405 A CN117274405 A CN 117274405A
Authority
CN
China
Prior art keywords
pixel point
cluster
led lamp
color
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311558387.8A
Other languages
Chinese (zh)
Other versions
CN117274405B (en
Inventor
李书贵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Lanfang Photoelectric Co ltd
Original Assignee
Shenzhen Lanfang Photoelectric Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Lanfang Photoelectric Co ltd filed Critical Shenzhen Lanfang Photoelectric Co ltd
Priority to CN202311558387.8A priority Critical patent/CN117274405B/en
Publication of CN117274405A publication Critical patent/CN117274405A/en
Application granted granted Critical
Publication of CN117274405B publication Critical patent/CN117274405B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/762Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02BCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO BUILDINGS, e.g. HOUSING, HOUSE APPLIANCES OR RELATED END-USER APPLICATIONS
    • Y02B20/00Energy efficient lighting technologies, e.g. halogen lamps or gas discharge lamps
    • Y02B20/40Control techniques providing energy savings, e.g. smart controller or presence detection

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Multimedia (AREA)
  • Quality & Reliability (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to the technical field of image processing, in particular to a machine vision-based LED lamp working color detection method, which comprises the following steps: converting the acquired RGB image of the LED lamp during working into an HIS image, performing coarse clustering on the color of the LED lamp through a DBSCAN clustering algorithm, reallocating boundary pixel points according to the tone change of each pixel point of a cluster corresponding to the adjacent LED lamp of the boundary pixel points, analyzing the halation characteristics of the LED lamp according to the halation change at the rest edge pixel points, constructing a halation eliminating index of each pixel point, eliminating the pixel points with the halation eliminating index larger than a threshold value to obtain a selected cluster, and judging whether the LED lamp is qualified or not according to the tone and color template difference of the pixel points in each selected cluster. Therefore, the detection of the working color of the LED lamp is realized, the problem that the detection of the working color of the LED lamp is inaccurate due to the interference of other light sources is solved, and the accuracy of the detection of the working color of the LED lamp is improved.

Description

LED lamp working color detection method based on machine vision
Technical Field
The application relates to the technical field of image processing, in particular to a machine vision-based LED lamp working color detection method.
Background
The operating color of an LED lamp is one of the important indicators of its quality and performance. By detecting the working color of the LED lamp, the LED lamp can be ensured to meet the specified color requirement in the production process. This helps to improve the quality and consistency of the LED product, and ensuring consistent operating color for each LED lamp is important to the overall appearance and function of the product when mass-producing the LED lamps. The LED lamp working color is detected, so that production problems possibly existing on a production line can be found and corrected in time, consistency of the LED lamps among different production batches is guaranteed, the LED lamps can be ensured to meet relevant standards and specifications through detecting the LED lamp working color, requirements of specific application scenes are met, potential fault conditions can be detected in time through detecting the LED lamp working color, maintenance or replacement measures are adopted in advance, and normal operation and service life of the LED lamps are guaranteed.
The existing LED lamp working color detection often adopts a color sensor to detect, the color sensor may be affected by ambient light, such as interference from other light sources such as a lighting lamp, which may lead to inaccurate color detection results, and the accuracy of the color sensor is limited by hardware and calibration quality thereof. In some cases, very subtle color changes of the LED lamp may not be captured, or certain specific colors may not be identified.
In summary, the invention provides the machine vision-based LED lamp working color detection method, which performs coarse clustering on the LED lamp colors by using a DBSCAN clustering algorithm, then analyzes halation characteristics and edge characteristics of the LED lamps by combining factors possibly causing errors, obtains a fine clustering result, and improves the accuracy of LED lamp working color detection.
Disclosure of Invention
In order to solve the technical problems, the invention provides a machine vision-based LED lamp working color detection method to solve the existing problems.
The invention discloses a machine vision-based LED lamp working color detection method, which adopts the following technical scheme:
one embodiment of the invention provides a machine vision-based LED lamp working color detection method, which comprises the following steps:
collecting LED lamp working images in an RGB color space, and obtaining LED lamp working images in an HSI color space, wherein the LED lamp working images are respectively recorded as RGB images and HSI images;
obtaining a foreground image of the HSI image according to the pixel value change in the RGB image; acquiring an H channel and I channel image of a foreground image of an HSI image; obtaining each cluster in the H channel image through a clustering algorithm; edge pixel points in the H channel image are obtained through edge detection; obtaining the brightness difference and tone difference of the edge pixel points according to the neighborhood change of each edge pixel point in the I channel and H channel images; taking edge pixel points with the brightness difference less than or equal to a preset first brightness threshold value and the tone difference greater than or equal to a preset first tone threshold value as boundary pixel points; obtaining a left adjacent cluster of the boundary pixel point according to the cluster to which each pixel point in the adjacent boundary pixel point belongs; obtaining a left adjacent deviation factor of the boundary pixel point according to the tone of each pixel point in the left adjacent cluster of the boundary pixel point; acquiring right-neighbor deviation factors of boundary pixel points by combining the tone of each pixel point in the right-neighbor cluster; obtaining corrected clusters of each cluster according to the left and right adjacent deviation factors of each boundary pixel point;
obtaining the color gradient of each pixel point in each correction cluster according to the tone value change in the neighborhood of each pixel point in each correction cluster; calculating a symbiotic matrix of each pixel neighborhood in the H channel quantized image by combining the gray level symbiotic matrix, and marking the symbiotic matrix as a color symbiotic matrix; obtaining a halation rejection index of each pixel point according to the color co-occurrence matrix and the color gradient of each pixel point neighborhood; obtaining selected clusters according to the halation rejection index of each pixel point in the modified clusters;
and judging whether the working color of the LED lamp is qualified or not according to the color tone of the pixel points in each carefully selected cluster.
Preferably, the obtaining the foreground image of the HSI image according to the pixel value change in the RGB image specifically includes:
converting the RGB image into a gray image, carrying out threshold segmentation on the gray image to obtain a binary image, and removing pixels with coordinates identical to background pixel coordinates in the binary image to obtain a foreground image of the HSI image.
Preferably, the obtaining the brightness difference and the hue difference of the edge pixel according to the neighborhood change of each edge pixel in the I-channel and H-channel images specifically includes:
for each edge pixel point, calculating the brightness average value of all pixel points in the neighborhood of the edge pixel point in the I channel image; calculating the absolute value of the difference between the brightness of the edge pixel point and the brightness average value, and recording the absolute value as a first absolute value of the difference; taking the absolute value of the first difference value as the brightness difference quantity of the edge pixel points;
in the H channel image, taking the tone average value of all pixel points in a cluster where the edge pixel points are located as a first average value; taking the tone average value of all the pixel points in the neighborhood of the edge pixel point as a second average value; calculating the absolute value of the difference between the first average value and the second average value, and recording the absolute value of the difference as the absolute value of the second difference; calculating the ratio of the absolute value of the second difference value to the second average value; and taking the ratio as the hue difference of the edge pixel points.
Preferably, the obtaining the left and right adjacent clusters of the boundary pixel point according to the cluster to which each pixel point in the boundary pixel point neighborhood belongs specifically includes:
and for each neighborhood of the boundary pixel points, acquiring the first two clusters which are ordered from large to small according to the number of the pixel points in the cluster, taking the cluster at the left side of the boundary pixel point as a left adjacent cluster, and taking the cluster at the right side of the boundary pixel point as a right adjacent cluster.
Preferably, the obtaining the left adjacent deviation factor of the boundary pixel point according to the hue of each pixel point in the left adjacent cluster of the boundary pixel point specifically includes:
removing all boundary pixel points in the boundary pixel point left neighbor cluster to obtain a cluster without boundary points; calculating the absolute value of the difference of the hue of each pixel point in the boundary pixel point and borderless point cluster; calculating the average value of all the absolute values of the differences; and taking the average value as a left adjacent deviation factor of the boundary pixel point.
Preferably, the corrected cluster of each cluster is obtained according to the left and right adjacent deviation factors of each boundary pixel point, specifically:
comparing the sizes of the left adjacent deviation factors and the right adjacent deviation factors for each boundary pixel point, and relocating the boundary pixel points into clusters with large deviation factors; and taking each cluster after the re-merging of all the boundary pixel points as each corrected cluster.
Preferably, the obtaining the color gradient of each pixel point in each modified cluster according to the change of the hue value in the vicinity of each pixel point in each modified cluster specifically includes:
in the H channel image, binary numbers of all pixel points are obtained through a local binary pattern; acquiring the gradient direction of each pixel point through a Sobel operator; for each pixel point in each correction cluster, calculating the Hamming distance between the pixel point and binary numbers of other pixel points in the neighborhood; calculating the average value of all the hamming distances; acquiring information entropy of angles corresponding to gradient directions of all pixel points in the neighborhood; calculating the sum of the mean value and the information entropy; and taking the sum value as the color gradient of the pixel point.
Preferably, the halo rejection index of each pixel is obtained according to the color co-occurrence matrix and the color gradient of the neighborhood of each pixel, and specifically includes:
for each pixel neighborhood, acquiring the number and probability of occurrence of the pixel combination with the quantized values of a and b in the neighborhood through a color co-occurrence matrix; calculating the square of the difference between the quantized values a and b; calculating the product of the square of the difference and the number of times; calculating the sum value of the products of all the pixel point combinations in the neighborhood, and recording the sum value as a first sum value; calculating the ratio of the probability to the square of the difference; calculating the sum value of the ratio of all the pixel point combinations in the neighborhood, and recording the sum value as a second sum value; taking the difference value of the first sum value and the second sum value as the texture gradient of the pixel point;
taking the product of the color gradient and the texture gradient of each pixel point as the halation eliminating index of each pixel point.
Preferably, the selecting cluster is obtained according to the halation rejection index of each pixel point in each correcting cluster, specifically:
presetting a second threshold value, and taking all cluster clusters obtained by eliminating pixel points with the halation eliminating index larger than the second threshold value in all corrected cluster clusters as all carefully chosen cluster clusters.
Preferably, the step of judging whether the working color of the LED lamp is qualified according to the color tone of the pixel points in each carefully selected cluster includes:
presetting a distance threshold; for each carefully chosen cluster, calculating the tone average value of all pixel points in the carefully chosen cluster; calculating the difference value between the tone mean value and the standard tone; if the difference value between the LED lamp and the standard color tone is smaller than the distance threshold value, the working color of the LED lamp is qualified; if the difference value between the LED lamp and the standard color tone is larger than or equal to the distance threshold value, the working color of the LED lamp is disqualified.
The invention has at least the following beneficial effects:
according to the invention, by combining the machine vision with the light-emitting characteristics of the LED lamp during working, the LED lamp working color detection method based on the machine vision is provided, the DBSCAN clustering algorithm is utilized to perform coarse clustering on the LED lamp colors, and then the halation characteristics and the edge characteristics of the LED lamp are analyzed by combining factors which possibly generate errors, so that a fine clustering result is obtained, the problem of poor clustering result caused by halation interference of the LED lamp is avoided, the problem of inaccurate color detection caused by interference of other light sources is solved, and the accuracy of the LED lamp working color detection is improved;
in order to avoid the problem that other light influences the color detection of the LED lamp, the acquired RGB image of the LED lamp during working is converted into an HIS image, and clustering clusters in an H channel image are acquired in a foreground image of the HSI image through a clustering algorithm; obtaining boundary pixel points in the image according to brightness and tone differences in the neighborhood of the edge pixel points in the image; obtaining left and right adjacent deviation factors of the boundary pixel point according to the tone change of each pixel point of the cluster corresponding to the LED lamp adjacent to the boundary pixel point; classifying each boundary pixel point into a cluster corresponding to a larger value in the left and right adjacent deviation factors, and correcting each cluster; obtaining the color gradient of each pixel point in each correction cluster according to the tone value change in the neighborhood of each pixel point in each correction cluster; constructing a halation rejection index of each pixel point by combining the color co-occurrence matrix of each pixel point neighborhood; removing pixel points with halation removal indexes larger than a threshold value to obtain carefully selected cluster clusters; and judging whether the LED lamp is qualified or not according to the difference of the hue of the pixel points in each carefully selected cluster and the color template, and having higher detection precision of the working color of the LED lamp.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions and advantages of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for detecting the working color of an LED lamp based on machine vision;
fig. 2 is a schematic diagram of boundary pixel points in an LED lamp working image.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following detailed description is given below of the specific implementation, structure, characteristics and effects of the machine vision-based LED lamp working color detection method according to the invention in combination with the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following specifically describes a specific scheme of the working color detection method of the LED lamp based on machine vision provided by the invention with reference to the accompanying drawings.
The invention provides a machine vision-based LED lamp working color detection method.
Specifically, the following method for detecting the working color of an LED lamp based on machine vision is provided, please refer to fig. 1, and the method comprises the following steps:
step S001, collecting an LED lamp working image of an RGB color space, and obtaining an LED lamp working image of an HSI color space.
And adopting a high-definition industrial camera to shoot an LED lamp working image of an RGB color space in a overlook mode at a fixed angle, determining the LED lamp working image as an RGB image, and taking the RGB image as an information source for detecting the working color of the LED lamp. It should be noted that, there are many methods for acquiring the working image of the LED lamp, and the specific image acquiring method can be set by the operator, and the embodiment is not limited specifically.
Then, since the HSI color space realizes quantitative description of colors by adopting a mode of separating hue H, saturation S and brightness I, the HSI color space is more in line with the understanding mode of the human visual system on colors relative to other color models, so that the LED lamp working image of the RGB color space is converted into the image of the HSI color space and is determined as the HSI image. Noise may be generated in the process of collecting and converting the image, so that the image of the LED lamp work in the HSI color space is denoised by adopting a median filtering algorithm. The process of converting the RGB image into the HSI image and the median filtering algorithm are well known in the art, and the specific process is not described in detail herein.
So far, the working images of the LED lamps in the RGB and HSI color spaces are respectively obtained.
Step S002, performing rough segmentation on the colors of the LED lamps through a DBSCAN clustering algorithm, and correcting the clustering result according to the segmentation result, the edge characteristics and the halation characteristics of the LED lamps to finally obtain a carefully selected cluster.
Firstly, in order to obtain an LED lamp flickering area in an LED lamp working image, removing a background area, firstly converting an RGB image into a gray image, and then dividing the gray image by using an Ojin threshold to obtain a binary image of the gray image, wherein the gray value of the foreground area is 1, and the gray value of the background area is 0. And replacing the gray value of the pixel point of the background area in the binary image with the gray value of the corresponding pixel point in the LED lamp working image of the HSI color space through coordinates to obtain the LED lamp working image of the HSI color space with the gray value of 0 of the background pixel point, and removing the pixel point with the gray value of 0 in the image, so that the background area in the LED lamp working image is removed, and the foreground area only comprising the LED lamp flickering area is obtained.
In order to analyze the color of the LED lamp, H, S, I channel separation is carried out on the foreground image in the HSI color space, an H channel image and an I channel image are respectively extracted, the single-channel image is extracted as a well known, and the specific process is not repeated.In the H channel image, counting the tone value of each pixel point aiming at the LED lamp flickering area, counting the number of the corresponding pixel points under each tone value, taking each tone value as the abscissa, taking the number of the corresponding pixel points under each tone value as the ordinate, obtaining an LED lamp color histogram, counting the minimum value of the ordinate value in the LED lamp color histogram, and marking the minimum value as the minimum valueThen, for each pixel point of the LED lamp flickering area, mark +.>The value corresponds to each pixel point in the H channel image, a set formed by the pixel points is used as a first set, euclidean distance between each pixel point in the first set and each other pixel point remained in the first set is calculated and compared, and the maximum Euclidean distance of the pixel point is obtained and is recorded as->And then clustering all pixel points of the LED lamp flickering area by using a DBSCAN clustering algorithm, wherein the setting of related parameters is as follows: neighborhood radius->Threshold->The DBSCAN clustering algorithm is a known technology, and will not be described herein.
After DBSCAN clustering, the LED lamps with different colors in the LED lamp flickering area are roughly classified into different clusters according to colors, the average value of the tone values of all pixel points in each cluster is calculated, and the average value is expressed as. Because the colors of the LED lamps are mutually interfered when the LED lamps work, especially when the colors of two adjacent LED lamps are similar, the pixel points at the edge connecting part of the two adjacent LED lamps can have clustering errors during clustering, therefore, DBSCA is singly adoptedThe N clustering algorithm can cause error in color clustering of the flickering area of the LED lamp, and the analysis is continued aiming at the problem.
Because the adjacent two LED lamps have the edge connected part, the pixel point on the connected edge line is determined as the boundary pixel point, as shown in figure 2, in order to acquire the boundary pixel point, firstly, edge detection is carried out on the H-channel image of the LED lamp flickering area through a Canny operator, each edge pixel point in the H-channel image is acquired, and for each edge pixel point, the edge pixel point is taken as the center pixel point to constructIn the neighborhood, the value of n can be set by the operator himself, and in the present embodiment, the value of n is set to +.>Calculating the brightness difference and the tone difference of each edge pixel point according to the distribution condition of colors in the neighborhood of each edge pixel point, wherein the expression is as follows:
in the method, in the process of the invention,、/>luminance, hue difference amount of edge pixel point q, +.>For the brightness value of the edge pixel point q, n is the neighborhood size of the edge pixel point q, +.>、/>Respectively, the brightness value, the tone value,/-of the ith pixel point in the neighborhood of the edge pixel point q>And determining the color tone average value of all the pixel points in the cluster where the edge pixel point q is located as a first average value. Wherein (1)>For the second mean>Is the absolute value of the first difference value,is the second absolute value of the difference.
When the edge pixel points are boundary pixel points, as the adjacent pixels are all the pixel points of the LED lamp, the brightness is very similar, and the brightness average value in the adjacent pixels is very small in brightness difference with the edge pixel points; when the edge pixel point is not the boundary pixel point, about half of the pixel points in the neighborhood are halation pixel points, and the halation brightness is far lower than the brightness of the LED lamp, so that the brightness average value in the neighborhood is larger than the brightness difference of the edge pixel point. For the color tone of the pixel point, if the edge pixel point is the boundary pixel point of the LED lamp, due to the color interference of the two LED lamps in the neighborhood, a certain error exists between the color average value in the neighborhood of the edge pixel point and the color average value of the cluster to which the edge pixel point belongs, and for the edge pixel point of the non-boundary pixel point, even though a certain difference exists between the color tone values of the pixel points in the neighborhood, the color tone value of the pixel points in the LED lamp halo is relatively smaller.
Thus setting the first brightness thresholdAnd a first tone threshold->It should be noted that->And->The value of (2) can be set by the practitioner himself, in this embodiment +.>And->The values of (2) are respectively set to +.>、/>. And when the brightness difference of the edge pixel point is smaller than or equal to a first brightness threshold value and the tone difference is larger than or equal to a first tone threshold value, taking the edge pixel point as the boundary pixel point.
And obtaining each boundary pixel point in the H channel image. Because each boundary pixel point of the LED lamps is also classified into each cluster, the DBSCAN cluster algorithm clusters through the density characteristic of the pixel points, if the colors of two adjacent LED lamps are similar, the pixel points on the connected boundary line are easy to generate the phenomenon of missing and wrong separation, so that firstly, for each boundary pixel point, in order to adaptively identify the cluster where two LED lamps adjacent to the boundary pixel point are located, the boundary pixel point is taken as the central pixel point to construct the boundary pixel pointNeighborhood, it is noted that +.>The value of (2) can be set by the practitioner himself, in this embodiment +.>The value is set to 5. Counting clusters in which each pixel point in the neighborhood is located, and obtaining two clusters with the largest pixel point occupation ratio in the neighborhood, wherein the two clusters are the LED lamps on the left side and the right side of the boundary pixel point neighborhoodAnd determining the corresponding cluster to be a left adjacent cluster by the cluster positioned at the left side of the boundary pixel point and determining the cluster positioned at the right side of the boundary pixel point to be a right adjacent cluster.
And then, eliminating all the boundary pixel points contained in the two clusters to obtain two clusters which do not contain the boundary pixel points, and respectively determining the two clusters as the clusters of the left and right adjacent boundary points of the boundary pixel points. According to the pixel points in the left adjacent non-boundary point cluster and the boundary pixel pointsIs to construct boundary pixel points +.>The expression is:
in the method, in the process of the invention,for boundary pixel points->Left neighbor deviation factor of->For boundary pixel points->The number of pixel points in the left adjacent borderless point cluster is>For boundary pixel points->Tone value of j-th pixel point in left adjacent borderless point cluster,/>For boundary pixel points->Tone value of>Is a normalization function. The larger the color difference between the boundary pixel point and each pixel point in the cluster, the more the boundary pixel point does not belong to the cluster, and the larger the deviation factor. Obtaining boundary pixel points in the above manner>Right neighbor deviation factor->. For each boundary pixel point +.>It comprises two deviation factors, namely +.>And->If->The color of the boundary pixel point is closer to that of the left LED lamp, and the boundary pixel point is classified into a left adjacent cluster; if->The color of the boundary pixel point is closer to the color of the right LED lamp, the boundary pixel point is classified into a right adjacent cluster, all the boundary pixel points are traversed to carry out the processing, and each obtained cluster is used as each correction cluster.
And correcting the boundary pixel points in each cluster according to the deviation factor of each boundary pixel point, so as to ensure that each pixel point in the corrected cluster is each pixel point of the same LED lamp. When the working color of the LED lamp is detected, halation can be generated when the LED lamp works, and the pixel points at the halation positions can influence the color identification of the LED lamp. Due to follow-upThe distance from the LED lamp is further and further, the halation of the LED lamp is gradually weakened, a certain gradient exists, and in the clustering process, the halation pixel points of the LED lamp are also more likely to be classified into each cluster, so that the pixel points in the H channel image are constructed by taking the pixel points as central pixel pointsNeighborhood, it is noted that +.>The value of (2) can be set by the practitioner himself, and the embodiment willThe value is set to 3. In a Local Binary Pattern (LBP), comparing the hue values of surrounding pixels in the neighborhood of the pixel point with the hue value of the central pixel point, if the pixel value of the surrounding pixels is larger than the pixel value of the central pixel point, marking the position of the surrounding pixels as 1, otherwise marking the surrounding pixels as 0, connecting the 1 and 0 according to a fixed sequence to obtain a binary number, wherein the binary number can be used as the LBP value of the central pixel point. In this embodiment, the local binary pattern is used to obtain the LBP value of the binary form of the pixel point, then the Sobel operator is used to calculate the gradient direction of the pixel point, and the angle corresponding to the gradient direction is obtained, where the local binary pattern and Sobel operator are known techniques, and the specific process is not repeated.
Then, for each pixel point in the correction cluster, the color gradient of each pixel point is constructed by integrating the indexes, and the specific expression of the color gradient is as follows:
in the method, in the process of the invention,to correct pixel point in cluster>Color gradation of>Is pixel dot +.>Is used to determine the neighborhood size of (1),is pixel dot +.>LBP value in binary form, +.>Is pixel dot +.>The x-th pixel point in the neighborhood,pixel dot +.>LBP value in binary form, +.>To calculate the hamming distance function +.>Is pixel dot +.>Is->Information entropy of angles corresponding to gradient directions of all pixel points in the neighborhood. If the hamming distance between the central pixel point and the LBP value of each pixel point in the neighborhood is larger, the color difference between the pixel points in the neighborhood is larger, so that the color gradient of the central pixel point is larger, and similarly, the information entropy of the gradient direction in the neighborhood is larger, the gradient direction distribution of the color in the neighborhood is more disordered, and the color gradient is larger.
For each cluster, selecting the pixel point with the largest gradient degree in the cluster, and recording the gradient direction of the pixel point asFor each pixel point in each cluster, constructing +.f. of the pixel point by taking the pixel point as the central pixel point>Neighborhood, it is noted that +.>The value of (2) can be set by the practitioner himself, this embodiment will +.>The value of (2) is set to +.>The color co-occurrence matrix of the neighborhood is calculated by combining the gray co-occurrence matrix, and the method specifically comprises the following steps: firstly, the original algorithm calculates through pixel gray scale, and the gray scale value is replaced by the tone value in the embodiment; then, normalizing the tone value of each pixel point in the H-channel image to be between 0 and 1, setting a quantization level N, wherein the value of N can be set by a user, in this embodiment, the value of N is set to be 4, the normalized tone value of each pixel point is quantized to N levels for simplifying data and reducing noise influence, and the quantized image is determined as a tone quantized image; then +.>A neighborhood, analyzing the quantization tone in the neighborhood through a sliding window, wherein the size of the sliding window is 1*2, and the sliding direction of the sliding window is +.>Counting the tone quantization value conditions in the sliding window, and obtaining a color co-occurrence matrix of the neighborhood according to the acquisition method of the gray co-occurrence matrix
Because the pixel point textures of the LED lamp are smooth and uniform, but the halation pixel points of the LED lamp gradually fade along with the distance between the halation pixel points and the LED lamp, and a certain gradient exists, the sliding direction of the sliding window in the construction process of the color symbiotic matrix is obtained through the color gradientThe change direction of the halation pixel points can be acquired more accurately, so that the color co-occurrence matrix better characterizes the halation pixel points, and each halation pixel point can be acquired accurately. The gray level co-occurrence matrix is a known technology, and the specific process is not described again.
In order to preserve the pixel points of the LED lamp, the halation pixel points in each cluster are required to be removed, and a halation removal index is constructed, wherein the halation removal index specifically comprises the following expression:
in the method, in the process of the invention,is pixel dot +.>Halation index of->Is pixel dot +.>Color gradation of>Is pixel dot +.>Texture gradient,/, of (2)>Quantization level of the image for H-channel, +.>For +.>Line->The element values of the columns represent the number of times that the combination of pixels with quantized values a and b in the H-channel quantized image occurs,for quantifying the probability of the combination of pixels with values a and b occurring in the image, i.e. the +.>Line->Ratio of column element values to sum values of all element values of the color co-occurrence matrix. />Representing the contrast of the gray level co-occurrence matrix as a first sum value; />Representing the inverse variance of the gray level co-occurrence matrix as a second sum value; the change of local textures of the pixel points is reflected, the larger the contrast is, the more obvious the texture gradual change degree is, the larger the texture gradual change degree is, the more likely the texture gradual change degree is a halation pixel point, and the greater the halation rejection index is; the smaller the inverse variance is, the larger the color difference is, the obvious texture change is, the larger the texture gradient is, the more likely the pixel points are halation pixels, and the greater the halation rejection index is; the greater the degree of color gradation, the more likely the pixel is a halo pixel, and the greater the halo rejection index.
Setting upSecond threshold valueIt should be noted that->The value of (2) can be set by the practitioner himself, this embodiment will +.>The value of (2) is set to 0.1. And normalizing the halation eliminating index of each pixel point, eliminating the pixel points with the normalized halation eliminating index being larger than a second threshold value as halation pixel points, wherein the pixel points in each correction cluster are all the pixel points of the LED lamp, determining each cluster at the moment as a carefully chosen cluster, and finishing correction of the DBSCAN cluster result to obtain a carefully chosen cluster result.
And step S003, comparing the hue of the pixel points in the selected cluster with a color template of a qualified standard to realize the detection of the working color of the LED lamp.
According to the obtained fine clustering result, taking the tone average value of the pixel points in each fine clustering cluster as the main color component of each clustering cluster, simultaneously obtaining the color template of the qualified standard to obtain the main color of the color template, then respectively calculating the Euclidean distance between the main color component of each clustering cluster and the main color component of the standard qualified color template, normalizing, and setting a distance threshold valueIt should be noted that->The value of (2) can be set by the practitioner himself, this embodiment will +.>The value of (2) is set to 0.1. If the calculated Euclidean distance is smaller than the distance threshold +.>Judging that the working color of the LED lamp is qualified, and if the calculated Euclidean distance is larger than the distanceLeave threshold->And judging that the working color of the LED lamp is unqualified.
In summary, the embodiment of the invention provides the LED lamp working color detection method based on machine vision by combining the machine vision with the luminous characteristics of the LED lamp during working, the DBSCAN clustering algorithm is utilized to perform coarse clustering on the LED lamp colors, and then the halation characteristics and the edge characteristics of the LED lamp are analyzed by combining factors possibly generating errors to obtain a fine clustering result, so that the problem of inaccurate color detection caused by interference of other light sources is avoided, and the accuracy of LED lamp working color detection is improved;
in order to avoid the problem that other light influences the color detection of the LED lamp, the acquired RGB image of the LED lamp during working is converted into an HIS image, and clustering clusters in the H channel image are acquired in the foreground image of the HSI image through a clustering algorithm; obtaining boundary pixel points in the image according to brightness and tone differences in the neighborhood of the edge pixel points in the image; obtaining left and right adjacent deviation factors of the boundary pixel point according to the tone change of each pixel point of the cluster corresponding to the LED lamp adjacent to the boundary pixel point; classifying each boundary pixel point into a cluster corresponding to a larger value in the left and right adjacent deviation factors, and correcting each cluster; obtaining the color gradient of each pixel point in each correction cluster according to the tone value change in the neighborhood of each pixel point in each correction cluster; constructing a halation rejection index of each pixel point by combining the color co-occurrence matrix of each pixel point neighborhood; removing pixel points with halation removal indexes larger than a threshold value to obtain carefully selected cluster clusters; and judging whether the LED lamp is qualified or not according to the difference of the hue of the pixel points in each carefully selected cluster and the color template, and having higher detection precision of the working color of the LED lamp.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. And the foregoing description has been directed to specific embodiments of this specification. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and the same or similar parts of each embodiment are referred to each other, and each embodiment mainly describes differences from other embodiments.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; the technical solutions described in the foregoing embodiments are modified or some of the technical features are replaced equivalently, so that the essence of the corresponding technical solutions does not deviate from the scope of the technical solutions of the embodiments of the present application, and all the technical solutions are included in the protection scope of the present application.

Claims (10)

1. The LED lamp working color detection method based on machine vision is characterized by comprising the following steps of:
collecting LED lamp working images in an RGB color space, and obtaining LED lamp working images in an HSI color space, wherein the LED lamp working images are respectively recorded as RGB images and HSI images;
obtaining a foreground image of the HSI image according to the pixel value change in the RGB image; acquiring an H channel and I channel image of a foreground image of an HSI image; obtaining each cluster in the H channel image through a clustering algorithm; edge pixel points in the H channel image are obtained through edge detection; obtaining the brightness difference and tone difference of the edge pixel points according to the neighborhood change of each edge pixel point in the I channel and H channel images; taking edge pixel points with the brightness difference less than or equal to a preset first brightness threshold value and the tone difference greater than or equal to a preset first tone threshold value as boundary pixel points; obtaining a left adjacent cluster of the boundary pixel point according to the cluster to which each pixel point in the adjacent boundary pixel point belongs; obtaining a left adjacent deviation factor of the boundary pixel point according to the tone of each pixel point in the left adjacent cluster of the boundary pixel point; acquiring right-neighbor deviation factors of boundary pixel points by combining the tone of each pixel point in the right-neighbor cluster; obtaining corrected clusters of each cluster according to the left and right adjacent deviation factors of each boundary pixel point;
obtaining the color gradient of each pixel point in each correction cluster according to the tone value change in the neighborhood of each pixel point in each correction cluster; calculating a symbiotic matrix of each pixel neighborhood in the H channel quantized image by combining the gray level symbiotic matrix, and marking the symbiotic matrix as a color symbiotic matrix; obtaining a halation rejection index of each pixel point according to the color co-occurrence matrix and the color gradient of each pixel point neighborhood; obtaining selected clusters according to the halation rejection index of each pixel point in the modified clusters;
and judging whether the working color of the LED lamp is qualified or not according to the color tone of the pixel points in each carefully selected cluster.
2. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the obtaining the foreground image of the HSI image according to the pixel value change in the RGB image specifically comprises:
converting the RGB image into a gray image, carrying out threshold segmentation on the gray image to obtain a binary image, and removing pixels with coordinates identical to background pixel coordinates in the binary image to obtain a foreground image of the HSI image.
3. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the obtaining the brightness difference and the hue difference of the edge pixel according to the neighborhood change of the edge pixel in the I-channel and H-channel images specifically comprises:
for each edge pixel point, calculating the brightness average value of all pixel points in the neighborhood of the edge pixel point in the I channel image; calculating the absolute value of the difference between the brightness of the edge pixel point and the brightness average value, and recording the absolute value as a first absolute value of the difference; taking the absolute value of the first difference value as the brightness difference quantity of the edge pixel points;
in the H channel image, taking the tone average value of all pixel points in a cluster where the edge pixel points are located as a first average value; taking the tone average value of all the pixel points in the neighborhood of the edge pixel point as a second average value; calculating the absolute value of the difference between the first average value and the second average value, and recording the absolute value of the difference as the absolute value of the second difference; calculating the ratio of the absolute value of the second difference value to the second average value; and taking the ratio as the hue difference of the edge pixel points.
4. The machine vision-based LED lamp working color detection method according to claim 1, wherein the obtaining the left and right adjacent clusters of the boundary pixel point according to the cluster to which each pixel point in the boundary pixel point neighborhood belongs specifically comprises:
and for each neighborhood of the boundary pixel points, acquiring the first two clusters which are ordered from large to small according to the number of the pixel points in the cluster, taking the cluster at the left side of the boundary pixel point as a left adjacent cluster, and taking the cluster at the right side of the boundary pixel point as a right adjacent cluster.
5. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the obtaining the left-neighbor deviation factor of the boundary pixel according to the hue of each pixel in the left-neighbor cluster of the boundary pixel specifically comprises:
removing all boundary pixel points in the boundary pixel point left neighbor cluster to obtain a cluster without boundary points; calculating the absolute value of the difference of the hue of each pixel point in the boundary pixel point and borderless point cluster; calculating the average value of all the absolute values of the differences; and taking the average value as a left adjacent deviation factor of the boundary pixel point.
6. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the corrected cluster of each cluster is obtained according to the left and right adjacent deviation factors of each boundary pixel point, specifically:
comparing the sizes of the left adjacent deviation factors and the right adjacent deviation factors for each boundary pixel point, and relocating the boundary pixel points into clusters with large deviation factors; and taking each cluster after the re-merging of all the boundary pixel points as each corrected cluster.
7. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the obtaining the gradient of the color of each pixel point in each modified cluster according to the change of the hue value in the vicinity of each pixel point in each modified cluster specifically comprises:
in the H channel image, binary numbers of all pixel points are obtained through a local binary pattern; acquiring the gradient direction of each pixel point through a Sobel operator; for each pixel point in each correction cluster, calculating the Hamming distance between the pixel point and binary numbers of other pixel points in the neighborhood; calculating the average value of all the hamming distances; acquiring information entropy of angles corresponding to gradient directions of all pixel points in the neighborhood; calculating the sum of the mean value and the information entropy; and taking the sum value as the color gradient of the pixel point.
8. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the obtaining the halation eliminating index of each pixel according to the color co-occurrence matrix and the color gradient of the neighborhood of each pixel specifically comprises:
for each pixel neighborhood, acquiring the number and probability of occurrence of the pixel combination with the quantized values of a and b in the neighborhood through a color co-occurrence matrix; calculating the square of the difference between the quantized values a and b; calculating the product of the square of the difference and the number of times; calculating the sum value of the products of all the pixel point combinations in the neighborhood, and recording the sum value as a first sum value; calculating the ratio of the probability to the square of the difference; calculating the sum value of the ratio of all the pixel point combinations in the neighborhood, and recording the sum value as a second sum value; taking the difference value of the first sum value and the second sum value as the texture gradient of the pixel point;
taking the product of the color gradient and the texture gradient of each pixel point as the halation eliminating index of each pixel point.
9. The method for detecting the working color of the LED lamp based on machine vision according to claim 1, wherein the selecting clusters are obtained according to the halation eliminating index of each pixel point in each correcting cluster, specifically:
presetting a second threshold value, and taking all cluster clusters obtained by eliminating pixel points with the halation eliminating index larger than the second threshold value in all corrected cluster clusters as all carefully chosen cluster clusters.
10. The machine vision-based LED lamp operating color detection method according to claim 1, wherein the determining whether the LED lamp operating color is acceptable according to the hue of the pixel point in each selected cluster is specifically as follows:
presetting a distance threshold; for each carefully chosen cluster, calculating the tone average value of all pixel points in the carefully chosen cluster; calculating the difference value between the tone mean value and the standard tone; if the difference value between the LED lamp and the standard color tone is smaller than the distance threshold value, the working color of the LED lamp is qualified; if the difference value between the LED lamp and the standard color tone is larger than or equal to the distance threshold value, the working color of the LED lamp is disqualified.
CN202311558387.8A 2023-11-22 2023-11-22 LED lamp working color detection method based on machine vision Active CN117274405B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311558387.8A CN117274405B (en) 2023-11-22 2023-11-22 LED lamp working color detection method based on machine vision

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311558387.8A CN117274405B (en) 2023-11-22 2023-11-22 LED lamp working color detection method based on machine vision

Publications (2)

Publication Number Publication Date
CN117274405A true CN117274405A (en) 2023-12-22
CN117274405B CN117274405B (en) 2024-02-02

Family

ID=89218118

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311558387.8A Active CN117274405B (en) 2023-11-22 2023-11-22 LED lamp working color detection method based on machine vision

Country Status (1)

Country Link
CN (1) CN117274405B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112200200A (en) * 2020-10-12 2021-01-08 蚌埠依爱消防电子有限责任公司 LED light color detection method
CN114463570A (en) * 2021-12-14 2022-05-10 江苏航天大为科技股份有限公司 Vehicle detection method based on clustering algorithm
CN115601367A (en) * 2022-12-15 2023-01-13 苏州迈创信息技术有限公司(Cn) LED lamp wick defect detection method
CN116007750A (en) * 2023-01-15 2023-04-25 联宝(合肥)电子科技有限公司 LED detection method, device, equipment, storage medium and system
CN116758083A (en) * 2023-08-21 2023-09-15 浙江莫克智造有限公司 Quick detection method for metal wash basin defects based on computer vision
CN116758528A (en) * 2023-08-18 2023-09-15 山东罗斯夫新材料科技有限公司 Acrylic emulsion color change identification method based on artificial intelligence

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112200200A (en) * 2020-10-12 2021-01-08 蚌埠依爱消防电子有限责任公司 LED light color detection method
CN114463570A (en) * 2021-12-14 2022-05-10 江苏航天大为科技股份有限公司 Vehicle detection method based on clustering algorithm
CN115601367A (en) * 2022-12-15 2023-01-13 苏州迈创信息技术有限公司(Cn) LED lamp wick defect detection method
CN116007750A (en) * 2023-01-15 2023-04-25 联宝(合肥)电子科技有限公司 LED detection method, device, equipment, storage medium and system
CN116758528A (en) * 2023-08-18 2023-09-15 山东罗斯夫新材料科技有限公司 Acrylic emulsion color change identification method based on artificial intelligence
CN116758083A (en) * 2023-08-21 2023-09-15 浙江莫克智造有限公司 Quick detection method for metal wash basin defects based on computer vision

Also Published As

Publication number Publication date
CN117274405B (en) 2024-02-02

Similar Documents

Publication Publication Date Title
CN116385439B (en) Motor rubber shock pad quality detection method based on image processing
CN111833306A (en) Defect detection method and model training method for defect detection
CN115115644A (en) Vehicle welding defect detection method based on artificial intelligence
CN111612737A (en) Artificial board surface flaw detection device and detection method
CN115100206B (en) Printing defect identification method for textile with periodic pattern
CN116703911B (en) LED lamp production quality detecting system
CN115311484B (en) Optimized clustering segmentation method for weld data
CN115082451A (en) Stainless steel soup ladle defect detection method based on image processing
CN113888536B (en) Printed matter double image detection method and system based on computer vision
CN112308854A (en) Automatic detection method and system for chip surface flaws and electronic equipment
CN108921857A (en) A kind of video image focus area dividing method towards monitoring scene
JP4901229B2 (en) Red-eye detection method, apparatus, and program
CN114878595B (en) Book printing quality detection method
CN111753794A (en) Fruit quality classification method and device, electronic equipment and readable storage medium
CN110942444A (en) Object detection method and device
CN108230334B (en) High-concentration wind-blown sand image segmentation method based on gray threshold
CN117274405B (en) LED lamp working color detection method based on machine vision
CN114998346B (en) Waterproof cloth quality data processing and identifying method
CN111489367A (en) Positioning method for automatically selecting feasible coding area of hub two-dimensional code
CN116758045A (en) Surface defect detection method and system for semiconductor light-emitting diode
KR100488014B1 (en) YCrCb color based human face location detection method
CN113223098B (en) Preprocessing optimization method for image color classification
CN114820707A (en) Calculation method for camera target automatic tracking
CN111563536B (en) Bamboo strip color self-adaptive classification method based on machine learning
CN114926661A (en) Textile surface color data processing and identifying method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant