I would like to remove noise exists in the background. the noise isn't in a standard pattern. I would like to remove the background noise and keep the text on white background.
This an image sample :
I used the below code very simple processing steps.
import cv2
import numpy as np
img = cv2.imread("noisy.PNG")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray = cv2.subtract(255,gray)
ret,thresh = cv2.threshold(gray,5,255,cv2.THRESH_TOZERO)
noisy_removal = cv2.fastNlMeansDenoising(thresh, None, 65, 5, 21)
cv2.imwrite("finalresult.jpg",255-noisy_removal)
Here is the output image:
How I can enhance this result
You can play around with contrast/brightness to remove background pixels as discussed in this post.
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
alpha = 2.5
beta = -0.0
denoised = alpha * gray + beta
denoised = np.clip(denoised, 0, 255).astype(np.uint8)
denoised = cv2.fastNlMeansDenoising(denoised, None, 31, 7, 21)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With