From: Matthieu on
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
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
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
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 ?