フィルターのクリア

i have seen the code of vegetation percentage and it works well..............and i had a doubt is that how we have to calculate the vegetation pixel count

2 ビュー (過去 30 日間)
a=0; b= 0; c=0; p=0; p1=0;
%pic=sprintf('E:\PPTFILES\img-thing.png') fnam=imread('E:\PPTFILES\images.png'); for mm = 1:size(fnam,1)
for nn = 1:size(fnam,2)
if (fnam(mm,nn,2) -10) > fnam(mm,nn,1) & (fnam(mm,nn,2)-10) > fnam(mm,nn,3)
fnam(mm,nn,1) = fnam(mm,nn,1);
fnam(mm,nn,2) = fnam(mm,nn,2);
fnam(mm,nn,3) = fnam(mm,nn,3);
a=a+1;
else
fnam(mm,nn,1) = 250;
fnam(mm,nn,2) = 250;
fnam(mm,nn,3) = 250;
b=b+1;
end
end
end
p = a / (a + b);
p1 = p * 100;
imshow(fnam); a = sprintf('Vegetation Pixel Count= %3d',a); b = sprintf('Non Vegetation Pixel count= %3d',b); c = sprintf('Percentage of area of veg is %3f %',p1); msgbox(a); msgbox(b); msgbox(c);

採用された回答

Image Analyst
Image Analyst 2016 年 12 月 24 日
You say you have the percentage already and want to know how to get the count. So simply multiply the percentage times the total number of pixels.
[rows, columns, numberOfColorChannels] = size(fnam);
count = vegPercentage * rows * columns;
Actually it looks like your (badly-named) "a" is already the count. You just probably didn't realize it because of the horribly non-descriptive name you chose for it.
  3 件のコメント
Image Analyst
Image Analyst 2016 年 12 月 25 日
Not sure you read my Answer or followed any of the links because you didn't format your code, you didn't attach your image, and you're still asking how to get the percentage. Look at your code. You're calling "a" the vegetation pixels and "b" the non vegetation pixels. So
p = a / (a + b);
is the vegetation area fraction, a number between 0 and 1. Then you multiply it by 100:
p1 = p * 100;
so now p1 is the vegetation percentage and has units of percent and is in the range 0 to 100.
For color segmentation tutorials, see My File Exchange.
BUGATHA VARALAKSHMI
BUGATHA VARALAKSHMI 2017 年 3 月 16 日
this is very helpful to me

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by