find distance from center pixel to next white pixel

3 views (last 30 days)
How can I find the center pixel in a normal window like 640 by 480 pixels..I attached my one reference image from this image I want to measure h1, h2, w1, w2 from this mid point.Is it possible to measure the unknown shape of images?
  2 Comments
Rik
Rik on 27 Mar 2018

You can generate a distance grid with the code below. Using find, you can find what you define as a high intensity pixel.

x_center=320;
y_center=240;
[X,Y]=meshgrid((1:640)-x_center,(1:480)-y_center);
distance_to_center=hypot(X,Y);
Rik
Rik on 27 Mar 2018

You can find the center point of a blob with regionprops:

stats = regionprops(your_binary_image);
centroid = stats.centroid;

Then you should be able to use find on the relevant row and column to find the outer edges of your shape.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!