Image averaging and its application in noise reduction

Source: Internet
Author: User

image averaging and its application in noise reduction comparative analysis of image average and average image in coping with salt/pepper/Gaussian/camera noise Overview:

Image averaging operation is a simple way to reduce image noise.

We can easily calculate an average image from the image list.

Assuming that all images have the same size, we can simply add these images and then divide the image by the number of images to calculate the average image.

algorithm steps:

The order in which the image is processed on the digital image in the list is as follows:

    • A. Enter or get a list of file names

    • B. Reading an image file from a list of paths, converting an array to add

    • C. Divide the cumulative result by the number of images, averaging

    • D. Building an average result as a picture

    • E. Output image

Programming Examples:
#-*-Coding:utf-8-*- fromPILImportImage fromPylabImport* fromNumPyImport*ImportOsList of file names for #通过目录路径获取其中具有特定后缀名 (JPG) def get_imlist(path):    return[Os.path.join (Path,f) forFinchOs.listdir (PATH)ifF.endswith ('. JPG ')]#读取路径列表中的图片, simply add and divide by the number of files def compute_average(imlist):Averageim = Array (Image.open (imlist[0]),' F ') forImnameinchimlist[1:]:Try: Averageim + = Array (Image.open (imname))except:PrintImname +' ... skipped 'Averageim/= Len (imlist)returnArray (Averageim,' Uint8 ')#通过样本文件夹路径获取图片样本Imlist = Get_imlist ("./photosource3")#进行图片平均Im_a = Compute_average (imlist)#显示图片Imshow (Im_a) show ()
Noise reduction--Salt and pepper noises:

Here I use the method mentioned in the previous blog ("Salt and pepper noise") to generate salt and pepper noise, using a 0.8 Snr (signal-to-noise ratio) for the same image to continuously generate 8 test images with a large amount of salt and pepper noise, and perform an average operation on them:


Salt and pepper noise generation saltandpeppernoise.py:

#-*-Coding:utf-8-*- fromPIL Import Image fromPylab Import * fromNumPy import*#读取图片, grayscale, and converted to arraysimg = im = Array (Image.Open('./source/test.jpg ').Convert(' L '))#信噪比SNR =0.8#计算总像素数目 sp, get the number of pixels to add to the noise NP = SP * (1-snr)Noisenum=int ((1-SNR) *img.shape[0]*img.shape[1])#于随机位置将像素值随机指定为0或者255 forIinchRange (Noisenum): randx=Random. Random_integers (0, img.shape[0]-1) randy=Random. Random_integers (0, img.shape[1]-1)if Random. Random_integers (0,1)==0: img[randx,randy]=0      Else: img[randx,randy]=255   #显示图像Gray () Imshow (IMG) show ()


Original

One of the salt and pepper noise plots (SNR = 0.8):

Average image (4 photos):

Average image (8 photos):

It can be seen that the average image has a certain noise reduction effect, and with the increase of the average picture, sharpness also increased significantly, relative to the salt and pepper noise, although the mean rate filter is lower than the SNR, the most commonly used algorithm to remove salt and pepper noise is median filter, but the intuitive effect is the best average, After all, it is based on a number of pictures of the noise reduction method. At the same time, in the face of Gaussian noise, still is the image averaging method in the visual effect is relatively good, below we test the Gaussian noise.

Noise Reduction-Gaussian noise:

Here I use the method mentioned in the previous blog ("Gaussian noise") to generate Gaussian noise, using Sigma = 30 for the same image to continuously generate 8 test images with a large amount of Gaussian noise, and the average operation:

Generation of Gaussian noise gaussnoise.py:

#-*-Coding:utf-8-*- fromPIL Import Image fromPylab Import * fromNumPy Import*importRandom#读取图片并转为数组im = Array (Image.Open('./source/test.jpg '))#设定高斯函数的偏移means =0#设定高斯函数的标准差Sigma = -#r通道r = im[:,:,0].flatten ()#g通道g = im[:,:,1].flatten ()#b通道b = im[:,:,2].flatten ()#计算新的像素值 forIinchRange (im.shape[0]*im.shape[1]): PR = int (R[i]) +Random. Gauss (0, sigma) pg = INT (g[i]) +Random. Gauss (0, sigma) PB = Int (B[i]) +Random. Gauss (0, Sigma)if(PR <0): PR =0    if(PR >255): PR =255    if(PG <0): PG =0    if(PG >255): PG =255    if(Pb <0): PB =0    if(Pb >255): PB =255R[i] = PR G[i] = PG B[i] = pbim[:,:,0] = R.reshape ([im.shape[0],im.shape[1]]) im[:,:,1] = G.reshape ([im.shape[0],im.shape[1]]) im[:,:,2] = B.reshape ([im.shape[0],im.shape[1]])#显示图像Imshow (IM) show ()

One of the Gaussian noise plots (sigma = 30):

Average image (4 photos):

Average image (8 photos):

It can be obvious that the average noise reduction effect of the image is still relatively obvious, with the increase of the average image, the sharpness gradually increased, according to a paper found from the Internet, the conventional method of noise reduction, the average image is the best method of visual effect.

Noise Reduction-camera noises:

Camera at high sensitivity to take photos will see a lot of noise, the higher the sensitivity of the more noise, the camera when taking photos generated by the noise from the sensor noise points.

Each pixel in the digital camera sensor has one or more photodiodes, which convert the photons that fall on the pixels into electronic signals, and then calculate the color values and other values that eventually form a complete image. If the same pixel is exposed several times in the same amount of light, the pixel's color values may vary, and these tiny differences form the noise of the sensor.

Even in the absence of light into the sensor, the electronic motion of the sensor itself generates some signals, and the additional signal is noise.

The smaller the pixel area, the more opportunities to generate noise, which is why small digital cameras are more likely to have more noise (compared to DSLR). Professional-grade cameras typically have high-quality pixels and powerful image processors, minimizing noise levels and even the presence of noise at high light sensitivity.

Here I use my dad's SLR to my childhood gouache in the same position with 25600 of the high ISO continuously took a group of samples, the photo is too large, the uploaded image has been compressed, in the end I will provide download links, the following is the average result:

Camera Noise Diagram Information:

One of the camera noise plots (ISO = 25600):

Average image (14 photos):

Can be more obvious, the red and blue ripple-like noise has basically disappeared, the effect is very ideal.

Conclusion:

This blog mainly introduces the image average and the average image in response to the salt/pepper/Gaussian/camera noise in the comparative analysis, in general, as the use of multiple photos of the noise reduction method, although the implementation and the principle is very simple, but the great degree of retention of the picture information, intuitive effect is very obvious, I hope this blog post to help you ~

Photo Sample:

http://download.csdn.net/detail/sunmc1204953974/9426150

Image averaging and its application in noise reduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.