フィルターのクリア

how to count number of elements greater than ?

209 ビュー (過去 30 日間)
menna gamal
menna gamal 2015 年 4 月 4 日
コメント済み: Image Analyst 2019 年 12 月 1 日
i'am new in matlab i want to the ways to count the number of formfactor in this code is greater than (e.g. 0.8)then this is normal Cell for example and print the number of normal and the number(abnormal) it is between (0.31-0.5)
hold on;
S =regionprops(Label,'area','perimeter');
for i=1:num
x(i)=S(i).Area;
y(i)=S(i).Perimeter;
%Form factor=4* pi * area/ (perimeter* perimeter)
form(i)=4.*pi.*x(i)./(y(i).^2);
end
i think to make array and if statement which save the true from if statement in array , and i try to make this :
NormalCount=sum(form(i)==1 || form(i)>=0.8);
AbnormalCount=sum(form(i)<0.8);
message1 = sprintf('Number of normal cells: %d %d',NormalCount);
message2 = sprintf('Number of Abnormal cells: %d %d',AbnormalCount);
msgbox({message1,message2});
But the result from this is wrong and i don't know this in for loop or i put it put ?
thanks.

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 4 月 4 日
編集済み: Geoff Hayes 2015 年 4 月 4 日
Menna - rather than using find just use the greater than operator to determine which elements of form are greater than 0.8 and then sum the result. Note that
form>0.8
will return an array of 0s and 1s where each zero indicates that the element in form at the index where the zero appears is not greater than 0.8, and each one indicates that the element in form at the index where the one appears is greater than 0.8.
For example, if
form = [0.1 0.9 0.83 0.33 0.22 0.44 0.99];
then
form>0.8
returns
0 1 1 0 0 0 1
as expected. Then just sum the result as
NormalCount = sum(form>0.8);
For your abnormal count, just do
AbnormalCount = sum(form>=0.31 & form<=0.5);
  6 件のコメント
Nicholas Prebble
Nicholas Prebble 2019 年 11 月 30 日
When I do this I recieve the error message "The logical indices contain a true value outside of the array bounds."
Error in practice (line 3)
NormalCount = sum(form>0.8);
Image Analyst
Image Analyst 2019 年 12 月 1 日
Nicholas, attach your m-file and image file so we can reproduce it and fix it. Preferably in a new thread.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by