count and plot red and blue colors from the pic
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Avia Lavon
am 24 Nov. 2022
Kommentiert: Avia Lavon
am 6 Dez. 2022
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 Kommentare
Akzeptierte Antwort
Ishan
am 1 Dez. 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!
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!