How to calculate distance between center of white pixels in an image?

In this iamge, I want to measure the distance between the center of area of white pixels marked below.
As these are not definite shapes, how do I find the center of these and then measure the distance in pixels between their centers.cmm_wo_circles.jpg

 採用された回答

KSSV
KSSV 2019 年 7 月 22 日

1 投票

REad about imdistline; this will allow you to calculate the distance between the points interactively. For this you are supposed to have image toolbox.
[y,x] = find(I==1) ; % give the pixel value
The above line, gives you the coordinates/ points of the required pixel. YOu have the points in hand, you can do the process needed.

2 件のコメント

Ritwik Dhar
Ritwik Dhar 2019 年 7 月 22 日
編集済み: Ritwik Dhar 2019 年 7 月 22 日
Thanks!
imdistline was what I was looking for.
But could there be some way I could directly code the center pixel co-ordinates to the imdistline arguments so that I can use this with large number of images.
KSSV
KSSV 2019 年 7 月 22 日
You can get the center of image using mean.

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

その他の回答 (1 件)

Teja Muppirala
Teja Muppirala 2019 年 7 月 22 日

1 投票

You can find the center (centroid) of each white region using REGIONPROPS, and then just calculate the distance between the centers that regionprops returns.

質問済み:

2019 年 7 月 22 日

回答済み:

2019 年 7 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by