count and plot red and blue colors from the pic
    8 views (last 30 days)
  
       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);
0 Comments
Accepted Answer
  Ishan
    
 on 1 Dec 2022
        Hi Avia, 
I ran your code for this image, and it gave a reading of 55.38 for red and 33.35 for blue. However, by plotting the recognized red and blue I believe you are trying to highlight certain sections of the image which lie in that range of hue which you desire. If that is the case, you can refer to the numerous colour segmentation methods listed on File exchange: - 
Hope this helps resolve your problem! 
More Answers (0)
See Also
Categories
				Find more on Color 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!
