Colour segmentation on resistor color band and calculate the value
Afficher commentaires plus anciens
hello guys i am trying to segment colour bands of a resistor using image processing and calculate the colours to give resistance . I am new to image processing any of your help is appreciated . i have come up with the code below but i am now stuck on how i can assign each colour band a number and do the calculations. Below the code is picture i am working with.
4 commentaires
reginald kwenda
le 24 Mar 2015
Modifié(e) : reginald kwenda
le 24 Mar 2015
reginald kwenda
le 24 Mar 2015
reginald kwenda
le 24 Mar 2015
reginald kwenda
le 24 Mar 2015
Réponses (3)
Image Analyst
le 24 Mar 2015
0 votes
Neither the lighting nor magnification is good enough to determine color robustly. Sorry, but the image is crummy. Zoom in and provide more light. Also, put the resistor in a jig to make sure it's positioned in the same place in each image.
3 commentaires
reginald kwenda
le 24 Mar 2015
Modifié(e) : reginald kwenda
le 24 Mar 2015
reginald kwenda
le 24 Mar 2015
reginald kwenda
le 24 Mar 2015
Image Analyst
le 25 Mar 2015
What I would do is to convert that image to LAB color space with rgb2lab(). Then find out the lab values of each color by looking at the images in the variable inspector. Then calculate a delta E (color difference) image for each know, predefined, fixed color. For example an image of the delta E between that lab image and the red color, then an image of the delta E between that lab image and the green color, and so on. Classify the pixel according to which delta E is least, meaning the color is closest to that color. I think you can do this if you insert the delta E images into a 3D matrix and then use min() across the third dimension and take the second output argument of min() as the classified image.
Delta E is just the sqrt of the delta L square plus... etc. For example to compute delta E between the image and the LAB of the red stripe:
deltaE = sqrt((L-lRed).^2 + (A - aRed).^2 + (B - bRed).^2);
Delta E is the industry standard metric for measuring color difference. Do the same for the green, blue, yellow, white, silver, gold, etc. colors.
14 commentaires
Image Analyst
le 25 Mar 2015
You can also use impixelinfo() to determine the lab values interactively by mousing around over the image.
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
Image Analyst
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
The RGB in the status line will actually be the LAB value. What values do you get for the different color stripes?
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
Image Analyst
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
Those must be the RGB values, not the LAB values. L does not go past 100. What are the LAB values?
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
Image Analyst
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
If you displayed the lab image, it should be shown in the Pixel info label. Maybe I'm wrong. I'll have to check the range of lab that it gives. I thought it was always 0-100, which is industry standard but maybe they scale it to 0-255 for some reason. See if it's any different if you cast to double first:
lab_he = applycform(double(rgbImage),cform);
There is also a one-step function you can use: rgb2lab(). Try that too.
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
Image Analyst
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
The formula for color difference is
deltaE = sqrt((L-lRed).^2 + (A - aRed).^2 + (B - bRed).^2);
L, A, and B are your lab_he(:,:,1), lab_he(:,:,2), and lab_he(:,:,3) images.
You said the lab for red is [117 193 175] so then
lRed = 117 % The L value of the red stripe.
aRed = 193 % The A value of the red stripe.
bRed = 175 % The B value of the red stripe.
Similarly for the other stripe colors.
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
reginald kwenda
le 25 Mar 2015
Déplacé(e) : DGM
le 12 Fév 2023
reginald kwenda
le 2 Avr 2015
Déplacé(e) : DGM
le 12 Fév 2023
reginald kwenda
le 2 Avr 2015
Déplacé(e) : DGM
le 12 Fév 2023
THINLAY GYALSON
le 16 Sep 2017
Modifié(e) : Walter Roberson
le 16 Sep 2017
0 votes
1 commentaire
Image Analyst
le 16 Sep 2017
Wow, people can get a published paper for this kind of super trivial, non-novel application? And the article didn't even say how they found the color bands and compared them to references.
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




