Hi,
I have created a for loop which loops through a number of columns on the image and finds the number of times that 0 (black colour) occurs in that column
for b=1:50
[c]=numel(find(img597(:,b,1)==0))
end
How do I find the corresponding value ( the column) where the maximum number of 0s has occured. The answer has to be 50

3 件のコメント

Jonas
Jonas 2021 年 4 月 19 日
the easiest way is to use
nrOfZeros=sum(img597(:,:,1)==0);
which gives you a row vector containing the number of zeros per column
colNrs=find(nrOfZeros==max(nrOfZeros),sum(nrOfZeros==max(nrOfZeros)))
colNrs then contains the numbers of columns with the maximum number of 0
Atheeb Amjard
Atheeb Amjard 2021 年 4 月 19 日
This is to find axis from an image. I am looping for the size of the number of columns to find the x axis and am looking to the same and find the y axis? how would I do that?
Jonas
Jonas 2021 年 4 月 20 日
it's the same procedure but with the first snippet being
nrOfZeros=sum(img597(:,:,1)==0,2);
which gives you a column vector with the number of 0 per row

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

 採用された回答

David Hill
David Hill 2021 年 4 月 19 日

0 投票

[~,idx]=max(sum(img597==0));

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2021 年 4 月 19 日

コメント済み:

2021 年 4 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by