Hello,
I need help in understanding why my code doesn't output quite what I thought it would. I am trying to measure the diameter of a vessel in a 512×512 image by measuring the diameter at several points and averaging the measurements. Here is my code
segmentLength = round(size(image,1)/segments); [rightrow, rightcol] = find(image==3); rightwall = [rightcol rightrow]; for j = 1:segmentLength:(size(image,1)-segmentLength) midpt = j+round(segmentLength/2); [~, midptcol] = find(image(midpt,:)==2); if isempty(midptcol)==0 [d, p] = min((rightwall(:,1)-midptcol).^2+(rightwall(:,2)-midpt).^2); %p is the row index of rightwall containing the nearest point
d = sqrt(d); diameter = [diameter d]; end end
I changed the value along the right side of the vessel to be 3 in order to identify what wall is the wall on the right and used 20 for my value of segments. When I graph the points to see what this code has done, the points with shortest distance don't seem to actually be those points (as far as I can tell with my eye) and so are not quite the diameter at that point. Can you help me understand what I am missing? Here is the image where the points on the right don't match up with where I would expect them to:
Thanks! Michael
Best Answer