필터 지우기
필터 지우기

problem with calculation of percentage of colormap

조회 수: 4 (최근 30일)
joanna
joanna 2013년 1월 10일
i want to calculate the percentage of high amount of "red" in an image of a colormap. what should be the equation i should input? 'stress' is a colormap image.
[image_1x image_1y] = size(stress);
for x = 1:image_1x
for y = 1:image_1y
if(stress(x,y) <=250) || (stress(x,y) >=255)
//???
end
end
end

답변 (1개)

Teja Muppirala
Teja Muppirala 2013년 1월 10일
You don't need to loop over every element one by one to do this. MATLAB is very good at doing operations on entire matrices in one command. You can simply write
L = 55; % Pick a level
percent_over = 100 * nnz(I > L) / numel(I)
This is basically counting the number of elements greater than L, and dividing it by the total number of elements in the image.
You can replace L with whatever value you would like to use (from your picture, "red" seems to be anything above about 50).
  댓글 수: 2
joanna
joanna 2013년 1월 10일
How do i convert the number into string and input it on the static text?
Image Analyst
Image Analyst 2013년 1월 10일
caption = sprintf('The number = %.3f', theNumber);
set(handleToStaticTextControl, 'String', caption);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by