MATLAB: How to find the distance between the outer most points of two objects in a binary image

binaryimage processingMATLAB

Hello everyone,
I have a series of images like the one shown below, which represent cracks in a steel specimen. Through various filters I got a binary image which includes the actual crack or cracks as the white objects. I would like to calculate the distance between the outer most Points (i.e. the crack tips). Because I have a large series of these images (several hundreds with slightly different cracks) I do not want to use imdist or similar manual functions to get the distance out of the image.binarytest.png

Best Answer

I = imread('download.png') ;
[y,x] =find(I) ;
% GEt bounding box of data
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
C = [x0 y0 ; x1 y0 ; x1 y1 ; x0 y1 ; x0 y0] ;
imshow(I)
hold on
plot(C(:,1),C(:,2),'r')
height = abs(y0-y1)