Extract contour of an image and plot it

3 views (last 30 days)
Hi,
I want to extract the contour from an image and plot the contours assuming the center of the image as the (0,0) coordinate system.
I have attached my image too.
Thanks for your help.
Picture4.png

Accepted Answer

Walter Roberson
Walter Roberson on 26 Apr 2019
im = rgb2gray( imread('Picture4.png') );
contour(im,4)
There is an obvious difference between specifying 2 (contour levels) or 3. However, you have to be looking fairly closely to tell the difference between 3 vs 4. You probably will not be able to tell the difference between 4 and 5.
The image appears to be consistent with the possibility that someone converted an image to black and white, and then write the image as jpeg, and then read in the jpeg and wrote it as png. That is, the values that are not 0 (black) or 255 (white) occur only in boundary positions as-if they only existed due to the way DCT handles sharp edges (it blurs them, like anti-aliasing.)
  11 Comments
Image Analyst
Image Analyst on 29 Jul 2023
@Jean-Parfait My demo does not reverse/invert the image intensities. I think you must have changed something. Nonetheless, I've updated a few lines in the demo and the updated code is attached.

Sign in to comment.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!