-1

I am working on image segmentation on a gray scale image using MATLAB. At present we have detected few edge points, which when joined together approximate to the shape of the object being detected.

I need the help in separating out only the object from the whole image. The background, i.e. the non-object area can be made fully black or white.

Please give me some hints on where to start.

It is possible to join each point with a line. How to translate the information in terms of those lines in classifying each pixel as belonging to object or background?

An example image of lungs is shown here, where the Left lung is the object and is retained as it is. The background is completely black.

enter image description here

m7913d
  • 10,244
  • 7
  • 28
  • 56
Prashant
  • 17
  • 7
  • Possible duplicate of [Image segmentation based on edge pixel map](https://stackoverflow.com/questions/18972932/image-segmentation-based-on-edge-pixel-map) – Shai May 25 '17 at 11:58
  • Please add what you tried so far. It is not the goal of SO to solve your complete task. – m7913d May 25 '17 at 12:47

1 Answers1

0

You are looking for the function poly2mask. Try

help poly2mask

An example use case:

t=linspace(0,2*pi,100);
a=(cos(t*3)+2)*20;
x=a.*cos(t)+60;
y=a.*sin(t)+60;
bw = poly2mask(x,y,120,120);
Jed
  • 193
  • 11