count and plot red and blue colors from the pic
Show older comments

I have a flourescence image (in tif format) with blue and red coloros
and i whant to quantify the amnmount of red and blue color in the picture
and draw/plot the recognized red and blue, to be able to check that I had choose a good range for recognizing red and blue colors.
I have this code to count the colors but i have not succeded to draw it
I would very appriciate your help.
RGB = imread('pic1.tif');
HSV = rgb2hsv(RGB);
[h,s,v] = imsplit(HSV);
hue = h*360;
[rows,cols] = size(hue);
num_pixels = rows*cols;
% red range: 0-20, 340-360
[red_ind, ~] = find(hue<=20 | hue>=340);
red_percentage = (length(red_ind)/num_pixels)*100;
fprintf('The red percentage of the image is : %.2f \n', red_percentage);
% blue range: 200-260
[blue_ind, ~] = find(hue<=260 & hue>=200);
blue_percentage = (length(blue_ind)/num_pixels)*100;
fprintf('The blue percentage of the image is : %.2f \n', blue_percentage);
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!