Krita Gaussian Noise Reduction

Filter 1: Noise Reduction

In everyday situations, there are always external signals that may interfere with the sounds that the hearing aid user actually wants to hear. This ability to distinguish a single sound in a noisy environment is a major concern for the hearing impaired. For people with hearing loss, background noise degrades speech intelligibility more than for people with normal hearing, because there is less redundancy that allows them to recognize the speech signal. Often the problem lies not only in being able to hear the speech, but in understanding speech signals due to the effects of masking. To adjust for this loss, we developed a noise reduction filter in MATLAB for our hearing aid.

Assumptions

To simplify our project, we assume
1) The filter will reduce noise independent of the level of hearing loss of the user, and
2) That any external signals, or noise, can be modeled by white Gaussian noise.

  • Wiener filter is a classical noise reduction method that is widely used for removing noises from the speech signal. In this paper, Wiener filter method based on frequency warping has been proposed for noise reduction process. The applied frequency warped method to the FIR filter is useful in noise reduction of speech signals and yields.
  • The simplest noise reduction method is the sliding mean or box filter (see ). Each pixel value is replaced by the mean of its local neighbours. The Gaussian filter is similar to the box filter, except that the values of the neighbouring pixels are given different weighting, that being defined by a spatial Gaussian distribution.

Krita - Free and open source digital painting application for Illustrators, comic artists, concept artists, matte painters etc. R/krita is for sharing artworks made in Krita, general help, tips and tricks, troubleshooting etc.

What is white Gaussian noise?

White Gaussian noise (WGN) has a continuous and uniform frequency spectrum over a specified frequency band and has equal power per Hertz of this band. It consists of all frequencies at equal intensity and has a normal (Gaussian) probability density function. For example, a hiss or the sound of many people talking can be modeled as WGN. Because white Gaussian noise is random, we can generate it in MATLAB using the random number generator function, random.

Procedure

Instead of adding white noise to a speech signal, we were able to obtain and generate several .wav sound files of a main speech signal with various sources of white noise in the background.

We experimented with implementing an FIR filter, but after researching various pre-existing MATLAB commands, we used the command wdencmp Ahnlab magniber decrypt. ,which performs noise reduction/compression using wavelets. It returns a de-noised version of the input signal using wavelet coefficients threshholding. We also utilized the MATLAB command ddencmp.

Microsoft office access 2013 for mac free download. Advantages of Using Wavelets

Wavelets are nonlinear functions and do not remove noise by low-pass filtering like many traditional methods. Low-pass filtering approaches, which are linear time invariant, can blur the sharp features in a signal and sometimes it is difficult to separate noise from the signal where their Fourier spectra overlap. For wavelets the amplitude, instead of the location of the Fourier spectra, differ from that of the noise. This allows for thresholding of the wavelet coefficients to remove the noise. If a signal has energy concentrated in a small number of wavelet coefficients, their values will be large in comparison to the noise that has its energy spread over a large number of coefficients. These localizing properties of the wavelet transform allow the filtering of noise from a signal to be very effective.While linear methods trade-off suppression of noise for broadening of the signal features, noise reduction using wavelets allows features in the original signal to remain sharp. A problem with wavelet denoising is the lack of shift-invariance, which means the wavelet coefficients do not move by the same amount that that the signal is shifted. Ths can be overcome by averaging the denoising result over all possible shifts of the signal. This works very well and even overcomes pseudo-Gibbs phenomena that is often seen due to lack of shift invariance.

Goal

In this chapter,

  • You will learn about Non-local Means Denoising algorithm to remove noise in the image.
  • You will see different functions like cv.fastNlMeansDenoising(), cv.fastNlMeansDenoisingColored() etc.
Noise

Theory

In earlier chapters, we have seen many image smoothing techniques like Gaussian Blurring, Median Blurring etc and they were good to some extent in removing small quantities of noise. In those techniques, we took a small neighbourhood around a pixel and did some operations like gaussian weighted average, median of the values etc to replace the central element. In short, noise removal at a pixel was local to its neighbourhood.

There is a property of noise. Noise is generally considered to be a random variable with zero mean. Consider a noisy pixel, (p = p_0 + n) where (p_0) is the true value of pixel and (n) is the noise in that pixel. You can take large number of same pixels (say (N)) from different images and computes their average. Ideally, you should get (p = p_0) since mean of noise is zero.

You can verify it yourself by a simple setup. Hold a static camera to a certain location for a couple of seconds. This will give you plenty of frames, or a lot of images of the same scene. Then write a piece of code to find the average of all the frames in the video (This should be too simple for you now ). Compare the final result and first frame. You can see reduction in noise. Unfortunately this simple method is not robust to camera and scene motions. Also often there is only one noisy image available.

So idea is simple, we need a set of similar images to average out the noise. Consider a small window (say 5x5 window) in the image. Chance is large that the same patch may be somewhere else in the image. Sometimes in a small neighbourhood around it. What about using these similar patches together and find their average? For that particular window, that is fine. See an example image below:

The blue patches in the image looks the similar. Green patches looks similar. So we take a pixel, take small window around it, search for similar windows in the image, average all the windows and replace the pixel with the result we got. This method is Non-Local Means Denoising. It takes more time compared to blurring techniques we saw earlier, but its result is very good. More details and online demo can be found at first link in additional resources.

For color images, image is converted to CIELAB colorspace and then it separately denoise L and AB components.

Image Denoising in OpenCV

OpenCV provides four variations of this technique.

  1. cv.fastNlMeansDenoising() - works with a single grayscale images
  2. cv.fastNlMeansDenoisingColored() - works with a color image.
  3. cv.fastNlMeansDenoisingMulti() - works with image sequence captured in short period of time (grayscale images)
  4. cv.fastNlMeansDenoisingColoredMulti() - same as above, but for color images.

Common arguments are:

  • h : parameter deciding filter strength. Higher h value removes noise better, but removes details of image also. (10 is ok)
  • hForColorComponents : same as h, but for color images only. (normally same as h)
  • templateWindowSize : should be odd. (recommended 7)
  • searchWindowSize : should be odd. (recommended 21)

Please visit first link in additional resources for more details on these parameters. Apowersoft screen recorder pro crack.

We will demonstrate 2 and 3 here. Rest is left for you.

1. cv.fastNlMeansDenoisingColored()

As mentioned above it is used to remove noise from color images. (Noise is expected to be gaussian). See the example below:

import cv2 as cv
dst = cv.fastNlMeansDenoisingColored(img,None,10,10,7,21)

Krita Gaussian Noise Reduction Systems

plt.subplot(121),plt.imshow(img)
plt.show()

Below is a zoomed version of result. My input image has a gaussian noise of (sigma = 25). See the result:

Krita Gaussian Noise Reduction

2. cv.fastNlMeansDenoisingMulti()

Now we will apply the same method to a video. The first argument is the list of noisy frames. Second argument imgToDenoiseIndex specifies which frame we need to denoise, for that we pass the index of frame in our input list. Third is the temporalWindowSize which specifies the number of nearby frames to be used for denoising. It should be odd. In that case, a total of temporalWindowSize frames are used where central frame is the frame to be denoised. For example, you passed a list of 5 frames as input. Let imgToDenoiseIndex = 2 and temporalWindowSize = 3. Then frame-1, frame-2 and frame-3 are used to denoise frame-2. Let's see an example.

import cv2 as cv
img = [cap.read()[1] for i in range(5)]
# convert all to grayscale
gray = [cv.cvtColor(i, cv.COLOR_BGR2GRAY) for i in img]
# convert all to float64
noise = np.random.randn(*gray[1].shape)*10

Krita Gaussian Noise Reduction System

# Add this noise to images
noisy = [np.uint8(np.clip(i,0,255)) for i in noisy]
Krita Gaussian Noise Reduction
# Denoise 3rd frame considering all the 5 frames
dst = cv.fastNlMeansDenoisingMulti(noisy, 2, 5, None, 4, 7, 35)
plt.subplot(131),plt.imshow(gray[2],'gray')
plt.subplot(133),plt.imshow(dst,'gray')

Below image shows a zoomed version of the result we got:

It takes considerable amount of time for computation. In the result, first image is the original frame, second is the noisy one, third is the denoised image.

Additional Resources

  1. http://www.ipol.im/pub/art/2011/bcm_nlm/ (It has the details, online demo etc. Highly recommended to visit. Our test image is generated from this link)
  2. Online course at coursera (First image taken from here)

Krita Gaussian Noise Reduction Software

Exercises