Problem with diff operating on a row vector from regionprops

1 回表示 (過去 30 日間)
Jason
Jason 2019 年 9 月 5 日
コメント済み: Jason 2019 年 9 月 5 日
Hello, I have an image which consists of 4 spots that I apply regionprops to:
area_measurements = regionprops(BW2,I,{'Area','Perimeter','MajorAxisLength','MinorAxisLength','Orientation','Eccentricity'});
I want to remove any spots that are different to the others. e.g the top left spot
I decided to use Major and Minor as my metric.
allMajor=[area_measurements.MajorAxisLength]
allMinor=[area_measurements.MinorAxisLength]
allMajor =
272.44 227.15 264.20 264.85
allMinor =
197.26 81.16 185.93 205.54
And then combine them, so
MM=[allMajor.*allMinor]
MM =
53742.57 18435.82 49121.64 54437.08
and then calc their differences to be able to remove the worst one. (I was thinking to remove the one with the largest difference and then take the mean)
y=diff(MM)
But this gives me an error:
Array indices must be positive integers or logical values.
I can't see why this is the case.

採用された回答

Nicolas B.
Nicolas B. 2019 年 9 月 5 日
編集済み: Nicolas B. 2019 年 9 月 5 日
Hi Jason,
I tried the following code:
MM = [53742.57, 18435.82, 49121.64, 54437.08];
y = diff(MM);
I get the following answer:
y =
1.0e+04 *
-3.5307 3.0686 0.5315
Are you sure that you don't have a variable or one of your functions that is named diff? It could be that you are shadowing the diff function.
  1 件のコメント
Jason
Jason 2019 年 9 月 5 日
AAhhh...yes I do, thanks for this
Jason

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by