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
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
Guillaume 2018-7-6
Jotheeshwar V's comment mistakenly posted as an answer moved here:
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
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
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
Jotheeshwar V
Jotheeshwar V 2018-7-8
编辑:Jotheeshwar V 2018-7-8
When I use my image, I am getting the error:
Out of memory. Type HELP MEMORY for your options.
I tried for a small image and that worked out
What should I do for this concern?
and the grid size of my file is, 11521x39842x3

请先登录,再进行评论。

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by