count and plot red and blue colors from the pic

3 次查看(过去 30 天)
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);

采纳的回答

Ishan
Ishan 2022-12-1
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!
  1 个评论
Avia Lavon
Avia Lavon 2022-12-6
Hi Ishan.
Thank you for your reply.
I am not the segmentation is what i am looking for.
By ploting recognized pixeles i just want to compare to original image by eye and check that my recognition was good enough.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by