Assignment 005: Noise reduction filter

The task is to implement a more advanced noise reduction method. The goal is to suppress noise but to keep as much information as possible, especially sharp edges.



The 005denoise project from the grcis repository will serve as a basis. A simple application is ready in which the user inputs the image and immediately the Filter.Recompute() method is automatically run that recomputes the filtered image. The output is then displayed in the window. Your task is to reprogram this method. The appropriate section of code is in the file Denoise.cs and is marked with brackets:

  // {{
  // }}

Technical details

The function Filter.Recompute() has the following parameters:
  • Bitmap input - input image (if it happens to be null, the function has to deal with it - it may also return null)
  • string param - optional string parameter. If used, it is your responsibility to define how the string will be interpreted. The pilot implementation recognizes several parameters: setting the window size, mode of the rank filter, setting of the size of the rectangle region - one or two numbers separated by a comma)
The return value is the recomputed image in the format Bitmap. It may be null.

If you do not want to use the fast (but more dangerous and less readable) variant of the access to image data, you don't have to - just use the code in the first branch (commented out using #if SLOW). Note: The slow version does intentionally not implement parallel computation. It did not yield any improvement - on the contrary, the program got slower due to the locking.

It is sufficient to denoise monochromatic (i.e. grayscale) images. The program will not be tested on any other data!

Programming details

The pilot implementation demonstrates several technical aspects:
  1. creation of the instance of the output raster image with the fixed format Format8bppIndexed
  2. fast access to binary pixel data - using the method Bitmap.LockBits() and the unsafe block using pointers into a locked memory arena (a slow alternative - with a different image format and with no parallelism - is also at your disposal)
  3. optional use of Parallel.For - when parallelism is on, the individual output scanlines are calculated in separate threads; everything is managed by the .NET runtime, you do not have to take care of anything else. What you do need to do, though, is to implement the cycle body using reentrant code.
  4. the calculation, as a whole, runs in a separate thread - it is necessary to regularly check the value of the global variable Form1.cont (when set to false, the algorithm should be aborted).
  5. Drag & Drop of the input image - the input image can be dropped into the form using a mouse from any Windows application that supports D&D.


N. Sladoje: Image analysis slides, Uppsala University, spring 2017, on line
Kuwahara/Nagao filtering, Wikipedia, on line
Lin Zhong et al.: Handling Noise in Single Image Deblurring using Directional Filters, Adobe Research, on line
Vinh Hong et al.: Edge Preserving Filters on Color Images, LNCS 3039:39-40, 2004, on line
A. Buades, B. Coll, J.M. Morel: "A review of image denoising methods, with a new one", Multiscale Modeling and Simulation, Vol4 (2), pp: 490-530, 2006, on line
A. Buades, B. Coll, J.M. Morel: "A non local algorithm for image denoising", IEEE Computer Vision and Pattern Recognition 2005, Vol 2, pp: 60-65, 2005, on line

What to hand in

Send me the source file Denoise.cs.
Parameter 'name' of the procedure InitParams() must return your name.
In the procedure InitParams() you may enter a set of suitable parameters, including a brief tooltip text.
If you have achieved a particularly nice result with a particular input image, you may also send this input. But beware of the attachment size - better to upload it somewhere (dropbox, google drive, etc.) and send the URL.

Into the source code, include a detailed comment on the origin of the implemented algorithm: did you come up with it yourself? Have you been inspired by the literature? Or by a filter from an existing program (PhotoShop, GiMP, ...), etc.


The due date is: 2. 12. 2018


Basis 8 pts, bonus up to 6 pts.


Visual Studio project: 005denoise.

Source file

Modify and hand in the file: Denoise.cs
In the function InitParams() write your name!


Your algorithm should work with any grey-scale image. For testing, you may use images from the repository folder data, for example Nadar-SarahBernhard1.png or noiseGauss05.png to noiseGauss20.png.

Copyright (C) 2010-2018 J.Pelikán and J.Křivánek last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)