Why centroid value is in float instead of integer?

2 ビュー (過去 30 日間)
saravanakumar D
saravanakumar D 2014 年 1 月 13 日
回答済み: Image Analyst 2014 年 1 月 13 日
I have eight white blog images in black background. When i was calculate centroid of each i get float type answers about four decimal(320.1425).
I have a doubt in this. All the images in taken as a matrix form right. Then the centroid will be only as integer. But actually it is not, why?

採用された回答

Image Analyst
Image Analyst 2014 年 1 月 13 日
Why do you think the centroid should be an integer? Is the average of two integers, 4 and 5, an integer? No - it's 4.5. So why should centroids be integer? You can round to the nearest integer if you want with the int32() function:
centroid_x_int = int32(centroid_x);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by