analytics

Wednesday, October 2, 2013

separating noise from information in a picture

Suppose you have a picture like:

It's easy for a person to tell where the two interesting objects are in this picture but I found a way for the computer to do it as well. 
Step 1: Make a new image where you look at each pixel in the original image and add up how far it's value is from it's neighbors. If it is exactly the same color as all it's neighbors that is a 0 if every surrounding pixel is exactly the opposite color that is a 255 (this means white in computer graphics). 
This has the effect of making all contiguous areas of color or gradients solid black.
Step 2:Make a new picture where the new pixels are the average of the old pixels and their neighbors. Sort of a blur. 
 Step 4. Blur again but only keep pixels that are between 0 black and 128 grey, everything else is made white. 
Now do the same thing again but only keep pixels that are between 0 black and 64 grey. All else stays white.
Now you should have a nice binary map of where the interesting parts of the original picture are with the noise removed. 

So it's kind of interesting to see what this process does to normal pictures...



It seems to work as an edge detector...

1 comment:

  1. Well, the first half of blog - this approach is similar to an aproach when you identify all black continuous areas, count the number of pixels within each one and get rid of areas that are less then x pixels big.
    Of course this work best for "binary" images when a pixel is either 0 or 1 (treshold for 0-255 values would do as well)

    ReplyDelete