Reputation: 623
I'm trying to de-noise an image which looks like this:
How can the white noisy pixels be removed? Initially I thought a median filter should suffice, but it doesn't look like it. Moreover, the image is RGB. Any thoughts?
I use Python.
(img: https://www.dropbox.com/s/aiyxkswtiyji7cw/exampledenoise.png?dl=0)
Upvotes: 1
Views: 1538
Reputation: 15575
Median blur, thresholding, comparisons, boolean expressions.
Unless you know why this picture was damaged and how, this is just guesswork.
In the PNG the defects all have an exact value of 255. Defects happen in dark areas of the picture. I'm guessing that something caused an underflow in those pixels, wrapping them from 0 or -1 to 255.
# using my own "imshow" shim for jupyter notebook, which handles boolean arrays
im = cv.imread("exampledenoise.png")
# imshow((im == 255).any(axis=2))
# estimating local brightness... so we DON'T "fix" bright spots
ksize = 13 # least value that appears to suppress all defects
med = cv.medianBlur(im, ksize=ksize)
# imshow(med)
# imshow(med >= 64) # candidate areas/channels.
# true = values likely explained by overexposure (don't fix)
# false = values likely explained by defect
fixup = (med < 64) & (im == 255)
assert len(fixup.shape) == 3 # fix individual channels
# imshow(fixup.any(axis=2)) # gonna fix values in these pixels
output = im.copy()
output[fixup] = 0 # assuming the damage was from some underflow, so 0 is appropriate
# imshow(output)
Upvotes: 3