MATLAB Answers

0

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

Asked by Ritwik Dhar on 22 Jul 2019
Latest activity Answered by Teja Muppirala
on 22 Jul 2019
Accepted Answer by KSSV
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

  0 Comments

Sign in to comment.

2 Answers

Answer by KSSV
on 22 Jul 2019
 Accepted Answer

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 Comments

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.
You can get the center of image using mean.

Sign in to comment.


Answer by Teja Muppirala
on 22 Jul 2019

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

  0 Comments

Sign in to comment.