Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV-removing noise from image

I'm working on a java image processing program(based on OpenCV library).

I need to remove the noise from the first image to get a clean image like the second image below.

In this specific case, what are the best ways to remove noise? The most important part is how to remove the black parts that surround the image.

First image:

enter image description here

Second image:

enter image description here

like image 833
Soheil Avatar asked Aug 02 '14 21:08

Soheil


1 Answers

  1. get rid of gray: threshold the image so that any gray becomes white
  2. get rid of border: floodfill at location (0.0) with white
  3. That will leave just a few remaining issues to clean up: detect each black blob in the image, if the area of a blob is less than some amount floodfill the blob with white. One way to implement that follows. Note that floodfill returns the number of pixels it filled. This allows you to scan for a black pixel, when you find one fill with gray. If the filled are is too small, fill again with white to erase the blob and then keep scanning, otherwise leave the blob as gray and keep scanning for black. At the end everything you want will be gray, so scan the image again and whenever you find gray flood fill with black.
like image 56
Bull Avatar answered Oct 14 '22 11:10

Bull