Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove monitor flickering noise from an image?

I'm trying to remove a noise from a photo of a monitor screen. Here's the source photo:

enter image description here

I've tried some different approaches, so the current version of my code is as follows:

clr_img = cv2.imread("D:\Noisy.jpg", 1) 
gray_img = cv2.cvtColor(clr_img, cv2.COLOR_BGR2GRAY) 
gray_img = cv2.fastNlMeansDenoising(gray_img, h=11)
binary_image = cv2.adaptiveThreshold(gray_img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 91, 12)

Here's the result:

enter image description here

Is it possible to get rid of this kind of the noise?

like image 682
SagRU Avatar asked Sep 19 '25 19:09

SagRU


1 Answers

You need to apply a smoothing operation before adaptive thresholding. A simple blur should help to reduce the noise. Any of these should work: Simple average blur (cv2.blur), Gaussian blur (cv2.GaussianBlur), or Median blur (cv2.medianBlur). Here's the result using a (7,7) Gaussian blur:

enter image description here

import cv2

image = cv2.imread('1.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (7,7), 0)
thresh = cv2.adaptiveThreshold(blur,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV,51,9)
result = 255 - thresh

cv2.imshow('thresh', thresh)
cv2.imshow('result', result)
cv2.waitKey()
like image 128
nathancy Avatar answered Sep 21 '25 11:09

nathancy