Example Code

Color and Grayscale Wiener Filter in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

1. Overview

This simple example showing the use case of Wiener Filter in image processing. Wiener filter is a method of restoring image in the presence of blur (and in general noise) in the case when the distortion signal (blur kernel in this case) is known. In the given example Gaussian blur was used. This algorithm also can be used from restoring “motion blurred” images.
Two very simple and straight forward examples illustrates the importance of knowing the function that caused the blur.

 

2. Description

A blurred or degraded image can be approximately described by equation Dst(x,y) = PSF * Src(x,y), where Src and Dst are source and result images and PSF is distortion operator called Point Spread Function. The Wiener filter can be understood better in the frequency domain. For deconvolution we will perform Fourier Transform of the blurred image, then perform convolution with inversed PSF function, and after inverse Fourier transform we will get the original image. When you know the exact PSF, the results of de-blurring can be really effective.
There are two examples – one for grayscale image and another one for color image. In case of color images this algorithm can be applied separately for each Red, Green and Blue planes. In this case the Picture Control was used (therefore Vision Toolkit is not required for this example).

 

3. Requirements

  • NI LabVIEW Professional Development System 2012 or above.

 

4. Steps to Implement or Execute Code

Drag and Drop snippet on Block diagram (or unzip attached archive and open VIs). Execute program. Blurred image shown on the left side and restored image shown on the right side. Change the sigma parameter and see how image will be restored in case of different PSF functions (The original image was blurred with sigma = 3).

 

5. Additional Information or References

Color Front PanelColor Front Panel

 

Color Block DiagramColor Block Diagram

 

Grayscale Front PanelGrayscale Front Panel

 

Grayscale Block DiagramGrayscale Block Diagram

 

 

 

**The code for this example has been edited to meet the new Community Example Style Guidelines.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
altenbach
Knight of NI Knight of NI
Knight of NI
on

Andrej

I don't think your algorithm will work with any kind of real-world situation. For example adding 10E-12 or higher gaussian noise to your BW image already kills it. (Long ago I deverloped some 1D Deconvolution regularizations that work well for most cases. Maybe I can adapt it for 2D. Let me look into this...)

WienerDogFilter.png

Andrey_Dmitriev
Active Participant
Active Participant
on

You should change PSF function according to added noise... But in general you're right, sure. Its an illustration of the main idea of wiener deconvolution. In given example the image deblurred with function which is exactly opposite to blurring function (and which is known by me). Of course is not positioned as "universal deblur solution" - therefore its just small example for exercise (like Wiener Filter example in Matlab), and not an imageprocessing toolkit for real world.