can any one tell me the meaning of the following lines

조회 수: 3 (최근 30일)
Anamika baruah
Anamika baruah 2014년 6월 15일
답변: Image Analyst 2014년 6월 20일
[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