Why regionprops some values looks like bugs?
2 次查看(过去 30 天)
显示 更早的评论
I have Tried Using regionprops with fields of Area, Centroid and BoundingBox. I was desappointed firstly when comparing results of my implementation of Centroid vs the ready Centroid field in regionProps when I find that they are sometimes mostly equally, but sometimes the regionprops centroids give very wrong results.
As for prove here is the values I get from boundingbox
value =
53.5000 36.5000 170.0000 635.0000
value =
41.5000 10.5000 152.0000 671.0000
value =
27.5000 51.5000 217.0000 622.0000
value =
49.5000 7.5000 177.0000 686.0000
value =
35.5000 631.5000 1.0000 1.0000
value =
49.5000 23.5000 180.0000 656.0000
value =
33.5000 471.5000 1.0000 1.0000
value =
41.5000 26.5000 207.0000 674.0000
value =
43.5000 358.5000 1.0000 1.0000
value =
46.5000 59.5000 204.0000 616.0000
value =
33.5000 36.5000 214.0000 632.0000
value =
31.5000 287.5000 1.0000 1.0000
value =
28.5000 29.5000 182.0000 646.0000
value =
56.5000 1.5000 187.0000 699.0000
Why are those 1's in the result??? it's not right at all.
0 个评论
采纳的回答
Image Analyst
2015-12-4
It's not a bug. Those particular blobs are only 1 pixel big, so the width and height are only 1 pixel. The width and height are measured in terms of whole pixels, while the bounding box goes from a half pixel to the left of the left-most pixel center to a half pixel to the right of the right-most pixel center.
A = [0 1 0 1 1 0]
measurements = regionprops(logical(A), A, 'Area', 'BoundingBox');
for k = 1 : length(measurements)
fprintf('For blob #%d\n the area = %.1f, \n and the bounding box = [%f, %f, %f, %f]\n',...
k, measurements(k).Area, measurements(k).BoundingBox);
end
and see
For blob #1
the area = 1.0,
and the bounding box = [1.500000, 0.500000, 1.000000, 1.000000]
For blob #2
the area = 2.0,
and the bounding box = [3.500000, 0.500000, 2.000000, 1.000000]
5 个评论
Image Analyst
2015-12-5
You can use bwareaopen(binaryImage, 1) or bwmorph(binaryImage, 'clean') to remove single pixels.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Conway's Game of Life 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!