Prev: Real Time Workshop - Loading Multiple Parameters from Workspace
Next: Distance from image points to contour
From: Matthieu on 4 Mar 2010 10:35 Hello, After overlaying a contour over an image of size 512x512, I need to know for each pixel in the image the distance to that contour. imshow(log(1+abs(E3(:,:))), [1 15]); colormap(jet);hold on [KX, KY] = meshgrid(1:512,1_512); [C, h] = contour(KX, KY, OMEGA0, kt, 'Color', 'r', 'Linewidth', 2); (OMEGA0 is a non-linear function of KX and KY, kt a scalar) Checking the C returned by contour function (trying to understand what the values correspond to), I tried to reconstitute it by the plot function but failed. Any help would be appreciated. Something vaguely related to it on Matlab central, though it seems too sophisticated for what I need : http://www.mathworks.com/matlabcentral/newsreader/view_thread/156475#722702 Regards M
From: Matthieu on 4 Mar 2010 10:54 Sorry for double post. This thread should be deleted, and answers hopefully come in the other one : http://www.mathworks.com/matlabcentral/newsreader/view_thread/275533
From: Image Analyst on 4 Mar 2010 11:41 Matthieu: If you have the Image Processing Toolbox, you can call bwdist() which gives distance transform(s). Just make an image where your contour is non-zero and your other pixels are zero and then call bwdist. The output image will have each pixel's value as the distance to the closest point on the contour.
From: Matthieu on 4 Mar 2010 18:03
Thanks for the suggestion. I had the second step in mind without knowing the name of the correct function to use. About the first step, how to build an image from the contours ? |