Convert binary image to a line plot

I have a image with the contours of an object I'm analyzing, this image is a binary image where it shows the contours of the object as white and the rest as black. And I have the object mesh.
What I'm trying to do is overlay the contour image, as a line plot, on the mesh plot so i can see where are the limits of the mesh and remove the excess mesh.

Answers (1)

Your mesh doesn't have the same x and y limits/ranges as the binary image so you might have to scale it, but it's basically like this
[y, x] = find(binaryImage); % Note: it's [y, x], NOT [x, y], because it's really [row, column].
hold on
plot(x, y, 'k.', 'MarkerSize', 20) % Adjust markersize to what you want.

5 Comments

It worked but now both images don't match. My binary image is way bigger than the mesh, besides, I have some negatives coordinates on the mesh and none on the binary image. I'm still not able to match them.
My mesh image is apparently inside the red box i draw
I finally could match the contours with the mesh but i still have the contours as points at not as a line. Is there anyway to connect the point to convert it to a line? So i can create a region inside the contours
Why do you want a mesh anyway?
How did you get your binary image? Why is it not one pixel wide? Did you not use bwperim or bwboundaries?
I don't know what this means: "but i still have the contours as points at not as a line"? I think of contours like isolevels, like curves at a particular elevation/altitude for a topographic map, or iso-gray level lines on a gray scale image. That is your definition of contour, and why do you expect it to be a line? If you want the list of (x,y) coordinates for the perimeter of the binary image to be in an oder where all the points are adjacent, then use bwboundaries.
I got my binary image using Edge command. And I need those as a line so I can remove the excess mesh (red in image)

Sign in to comment.

Categories

Asked:

on 6 Jun 2022

Commented:

on 7 Jun 2022

Community Treasure Hunt

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

Start Hunting!