The last image is obtained by bwboundaries. Im guessing this could be used. I see the output B is the x,y locations of the perimeter - perhaps a centroid could be calculated and then some how the max and min distance from this centroid? This is what I've managed to do, not sure if its correct or the best way - it does look right
[B,L] = bwboundaries(bw2,'noholes');
disp('Boundaries')
B
BB=B{1} ;
X=BB(:,1); Y=BB(:,2);
figure
plot(X,Y,'k-','Linewidth',3);
%try and get centroids of these X,Y locations (of the perimeter)
hold on
plot(mean(X(:)),mean(Y(:)),'r+'); axis equal; grid on;
%hold off
%now calc distance of each point from the centroid
data=[];
cenX=mean(X(:)); cenY=mean(Y(:));
for i=1:length(BB)
X=BB(i,1); Y=BB(i,2);
data(i,1)=X; data(i,1)=Y;
R=sqrt((X-cenX)^2+(Y-cenY)^2)
data(i,3)=R;
end
R1=max(data(:,3))
R2=min(data(:,3))
viscircles([cenX, cenY], R1, 'Color', 'b','Linewidth',1);
viscircles([cenX, cenY], R2, 'Color', 'r','Linewidth',1); hold off;