필터 지우기
필터 지우기

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에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by