0

I have some processed images that have noise (background pixels) around the boundaries. Is there a way to detect only the boundary of the object itself and create a mask to remove the background pixels around the boundaries?

Im a beginner to OpenCV so any code samples would help.

Example:

Original Image

enter image description here

Processed Image

Input image

Expected Output

Input image

I have tried the findContours method but it creates a mask that includes the noisy pixels as well.

Also i have tried the erode method but it does not give the same results for different image sizes so that is not the solution im looking for.

Daniyal Arshad
  • 251
  • 1
  • 3
  • 6
  • do you have the image with full original background, too? You could try to use gradient information to improve the mask (active contours, edge detection, iterative blurring, pyramidal approaches, color clustering, ...) but dont expect perfect results in general. – Micka Apr 21 '20 at 10:02
  • I usually use a combination of laplacian and color thresholding. Compute the laplacian of the greyscale image, and within each edge in the laplacian, remove the pixels within a cretain threshold of color. You can use this with region detection algorithms to get better results. – Susmit Agrawal Apr 21 '20 at 10:35
  • You have to go for Deep learning image segmentation only this is impossible to do with image processing. – Pritul Dave Apr 21 '20 at 13:35

0 Answers0