can any one tell me the meaning of the following lines

2 views (last 30 days)
[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 Comments
Geoff Hayes
Geoff Hayes on 15 Jun 2014
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 on 15 Jun 2014
...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.

Sign in to comment.

Answers (1)

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

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!