Search code examples
matlabthickness

How to find thickness of segmented part of image in matlab?


I want to find the average thickness of a part which I am segmented, so I want to find the average pixel length in between the two borders (see below). How is it possible?

Image


Solution

  • I would use the pdist 2 function:

    A = [1,3; 
         2,3; 
         3,3];
    B = [1,4; 
         2,5; 
         3,6];
    
    dist = pdist2(A,B,'Euclidean','Smallest',1)
    
    mean(dist)
    

    This calculates the smallest distance possible between every point in the two vectors, and then returns the mean of this.