matlab - Get the middle/center pixel of a segmentation -
i have segmented image. wish extract middle pixel(s) of each segmentation. goal extract mean color middle pixel.
the following diagram illustrates mean 'middle pixel':
the alternative middle pixels
acceptable.
what algorithms/functions available in matlab
achieve similar this? thanks.
if i'm understanding want correctly, you're looking centroid. matlab has regionprops
function measures properties of separate binary objects long objects.
you can use centroid
property. assuming image stored in im
, binary, do:
out = regionprops(im, 'centroid');
the output structure array of n
elements n
corresponds total number of objects found in image. access ith object's centroid, do:
cen = out(i).centroid;
if wish collect centroids , place them perhaps in n x 2
numeric array, work:
out = reshape([out.centroid], 2, []).';
each row centroid of object found in image. take note object considered blob of white pixels connected each other.
Comments
Post a Comment