Problem with diff operating on a row vector from regionprops

1 次查看(过去 30 天)
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.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by