How to Read the pixels and state what are all the colors that are present in the Image?
1 次查看(过去 30 天)
显示 更早的评论
I have plotted the graph using geoshow.
I need to read the pixels and validate the data by counting the respective colors.
So, I want to know what are the colors present in the Image. I have checked that with paint picker. But, there are number of colors.
Is it possible to read the image and list the colors in the form of color code RGB?
If possible, kindly help me out of this.
3 个评论
Walter Roberson
2018-7-6
Do you want just the list of unique RGB triples? That is quite easy.
Do you want the "color name" for each RGB triple? That is more difficult, but you could start with the over 1500 named colors at https://en.wikipedia.org/wiki/List_of_colors_(compact) and you could read https://blog.xkcd.com/2010/05/03/color-survey-results/ (read it multiple times)
Do you want the named "primary" color for each RGB triple? That is hardest, as we have a very tough time defining exactly where "blue" ends and the next major color starts. Mechanical definitions based upon octant of the RGB color are not very good at aligning with human experience.
Guillaume
2018-7-6
I don't need the color name. The color indication in redchannel, greenchannel and bluechannel values. Like 255, 255, 255 for white.
and By the way, it is radar-gram of the ground surface and the plot is
https://drive.google.com/open?id=1AHilH-DD7AlSDxrReZ35ZO-06My-G84M
Regards,
Jotheeshwar
采纳的回答
Walter Roberson
2018-7-6
[uniquergb, ~, groupnumber] = unique(reshape(YourImage, [], 3),'row');
groupcounts = accumarray(groupnumber);
Now the RGB triple uniquergb(K,:) occurred groupcounts(K) times.
5 个评论
Walter Roberson
2018-7-8
YourImage = imread('peppers.png');
[uniquergb, ~, groupnumber] = unique(reshape(YourImage, [], 3),'rows');
groupcounts = accumarray(groupnumber, 1);
[sortedcounts, sortidx] = sort(groupcounts, 'descend');
N = 10;
most_common_rgb = double( uniquergb(sortidx(1:N),:) );
most_common_counts = sortedcounts(1:N);
fprintf('The most common colors are:\n count @ [r, g, b]\n');
fprintf('%g @ [%g, %g, %g]\n', [most_common_counts, most_common_rgb].' ); %transpose is important
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!