can any one tell me the meaning of the following lines

1 次查看(过去 30 天)
[index, map]=rgb2ind(I,65300);
pixels= prod(size(index));
hsv=rgb2hsv(map);
h = hsv(:,1);
s = hsv(:,2);
v = hsv(:,3);
darks = find(v <.2)';
lights = find(s < .05 & v > .85)';
h([darks lights])= -1;
disp(length(darks))
black = length(darks)/pixels;
white = length(lights)/pixels;
red = length(find((h >.9167 | h <=.083) & h~=-1))/pixels;
yellow=length(find(h >.083 & h<=.25))/pixels;
green=length(find(h > .25 & h<= .4167))/pixels;
cyan= length(find(h > .4167 & h<= .5833))/pixels;
blue=length(find(h > .5833 & h <= .75))/pixels;
magenta=length(find(h > .75 & h <= .9167))/pixels;
hold on
fill([0 0 1 1], [0 red red 0], 'r')
fill([1 1 2 2],[0 yellow yellow 0], 'y')
fill([2 2 3 3],[0 green green 0], 'g')
fill([3 3 4 4],[0 cyan cyan 0], 'c')
fill([4 4 5 5],[0 blue blue 0], 'b')
fill([5 5 6 6],[0 magenta magenta 0], 'm')
fill([6 6 7 7],[0 white white 0], 'w')
fill([7 7 8 8],[0 black black 0], 'k')
axis([0 8 0 1])
  2 个评论
Geoff Hayes
Geoff Hayes 2014-6-15
Luna - is there any line in particular that you are questioning or is it all of it? (I noticed that you have referenced this code in a couple of other questions today: question 1 and question 2.)
The best way to figure out what is happening is to step through the code and observe what is happening at each line.
dpb
dpb 2014-6-15
...best way to figure out what is happening is to step through the code and observe...
Preceded by or contemporaneous with reading the documentation for any functions you don't follow and using the examples for them in (generally) simpler conditions.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2014-6-20
It's counting the number of pixels with those particular colors.

类别

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