フィルターのクリア

How to use a floating point number in max() function?

4 ビュー (過去 30 日間)
Dominic
Dominic 2017 年 8 月 13 日
回答済み: Stephen23 2017 年 8 月 13 日
Hi, I am trying to find a maximum number that is a float number using max().
allWidths = bb(3:4:end);
allHeights = bb(4:4:end);
aspectRatio = [allWidths./allHeights ; allHeights ./ allWidths];
aspectRatios = max(aspectRatio, [], 0.5);
but the line
aspectRatios = max(aspectRatio, [], 0.5);
shows an error. How could I use a floating point number to find the maximum value??
  2 件のコメント
Stephen23
Stephen23 2017 年 8 月 13 日
編集済み: Stephen23 2017 年 8 月 13 日
max(aspectRatio, [], 0.5);
What is the 0.5-th dimension of an array?
Why not simply:
max(aspectRatio)
Dominic
Dominic 2017 年 8 月 13 日
No. Actually I have some blobs in a binary image and have calculated aspect ratios. Now I want to keep only those who have aspect ratios from 0.5 to 1.5.
0.5 is the lowest value that i want to set first in the variable aspectRatios and after that i have applied another condition to set maximum value 1.5 by following statement.
keeperIndexes = find(aspectRatios < 1.5);
but i am unable to set 0.5 in lowest. if there is a simple way to keep those blob in the binary image that has aspect ratio from 0.5 to 1.5 please share.

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

採用された回答

Stephen23
Stephen23 2017 年 8 月 13 日
aspectRatio = allWidths./allHeights;
idx = aspectRatio>0.5 & aspectRatio<1.5;
find is likely not required, as logical indexing is simpler and more efficient.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by