i need to plot the reflectance spectrum of coloured surface with 4 types of LEDs.

4 views (last 30 days)
I have different coloured surfaces like red cardboard, blue cardboard, green surface. I have taken 4 images of each of these surfaces with 4 LEDs red, green, blue and white. my task is to plot the reflectance spectrum of each coloured surface vs wavelength of visible light. by using RGB colour space, I separated the images into separate R,G and B planes, took mean values of each plane and plotted them again respective wavelengths. My first question is ,is it right way to plot the reflectance vs wavelength spectrum? are the intensity values of the RGB image reflectance values? Now I need to add more colours to the wavelengths i.e. colours like orange, yellow should be added and their reflectance values need to be plotted. I have taken range of red, green and blue and detecting whether yellow colour values are present in the image, as the LED is red and surface is green I should get some values of yellow as well. I have also tried the HSI colour space. But I am not getting how to check the values for particular colour from HSI colour space. here is my code:
clc;clear all;close all;
ired=imread('H:\images\green_plate\red_led\7.jpg');
% crop central part
ired=imcrop(ired);
figure,imshow(ired);title('original_img');
% separate RGB planes
iredr=ired(:,:,1);figure,imshow(iredr);title('red_img');
iredg=ired(:,:,2);figure,imshow(iredg);title('green_img');
iredb=ired(:,:,3);figure,imshow(iredb);title('blue_img');
% find the mean reflectance values
mr=mean2(iredr);
mg=mean2(iredg);
mb=mean2(iredb);
% show the red,green, blue images
iredr=ired(:,:,1);figure,imshow(iredr);title('red_img');
iredg=ired(:,:,2);figure,imshow(iredg);title('green_img');
iredb=ired(:,:,3);figure,imshow(iredb);title('blue_img');
% take the size of cropped image
[row,col]=size(iredr);
% set the counter for no. of pixels with orange values
orangecnt=0;
% create new image with values of orange pixels only
iredor=uint8(zeros(row,col));
% scan image for range of R,G,B values for orange colour combination
for x=1:1:row-2
for y=1:1:col-2
if(253<iredr(x,y)<255 && 128<iredg(x,y)<130 && 0<iredb(x,y)<30)
orangecnt=orangecnt+1;
iredor(x,y)=(iredr(x,y)+iredb(x,y)+iredg(x,y))/3;
end
end
end
display(orangecnt);
% find the reflectance value of orange colour
mo=mean2(iredor);
figure,imshow(iredor);title('orange_img');
% same for yellow colour
yellowcnt=0;
iredyl=uint8(zeros(row,col));
for x=1:1:row-2
for y=1:1:col-2
if(253<iredr(x,y)<255 && 253<iredg(x,y)<255 && 0<iredb(x,y)<10)
yellowcnt=yellowcnt+1;
iredyl(x,y)=(iredr(x,y)+iredg(x,y)+iredb(x,y))/3;
end
end
end
display(yellowcnt);
myl=mean2(iredyl);
figure,imshow(iredyl);title('yellow_img');
% plot the reflectance spectrum
x = [470,500,580,600,700]; %wavelengths of blue,green,yellow,orange,red
yred = [mb,mg,myl,mo,mr];
h1 = figure,plot(x,yred,'r');
title('reflectance vs wavelength plot of green plate');
xlabel('wavelength') % x-axis label
ylabel('reflectance values') % y-axis label

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!