Denoising

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Denoising

Phase GmbH
Hi,

I would like to clean images taken with an  CCD camera in long term shutter mode. Those images become noisy because of the CCD's dark current. The noise consists of pixels enlighted by the dark current.

A basic concept of denoisng is to take a second image at identical exposure conditions but the light path closed (dark image). Thereafter the dark image is used as a template to identifiy noisy pixels in the image taken with open light path.  The noisy pixels are then cleaned by assigning the average of the neighbour pixels.

Is there a plugin which is doing this job of replacement?

Regards

Christian
Reply | Threaded
Open this post in threaded view
|

Re: Denoising

Gabriel Landini
On Saturday 16 July 2005 12:06, Phase GmbH wrote:
> I would like to clean images taken with an  CCD camera in long term shutter
> mode. Those images become noisy because of the CCD's dark current.
> A basic concept of denoisng is to take a second image at identical exposure
> conditions but the light path closed (dark image). Thereafter the dark
> image is used as a template to identifiy noisy pixels in the image taken
> with open light path.  The noisy pixels are then cleaned by assigning the
> average of the neighbour pixels.

In brightfield microscopy this is usually done by just subtracting the
dark-field image (the one taken with the light path closed) from the
original.
However, this may not work every time because if the shutter time is very
long, the integration may result in the bright pixels becoming saturated, and
the subtraction results in black pixels.

The macro below does what you need:
Finds the single pixels which are saturated (i.e. 255)
finds the average of their 8 neighbours (or the median),
subtracts the bright pixels from the original (makes them black)
adds the average or median to the original (replaces the black with the new
values).

If the bright pixels are not saturated, you can modify the macro and use a
manual threshold instead of 255.
Mind the line breaks introduced by the mail editor.
You'll need the Particles8 plugin available at:
// http://www.dentistry.bham.ac.uk/landinig/software/software.html

Cheers,

Gabriel

PS: Wayne, if you find it useful, feel free to add it to the macros pool.

//-------------------->8--------------------------
// SaturatedPixelDenoising.txt
// G. Landini 16/July/2005
// This macro detects saturated *single* pixels (8 connected) in the
// image (grey=255) and replaces them with the pixel value of
// either the mean or the median of the neighbours (choose which
// method one by  un-commenting the lines indicated below.
// Works with 8bit and 24 bit images only.
// Needs the Particles8 plugin available at:
// http://www.dentistry.bham.ac.uk/landinig/software/software.html

run("Duplicate...", "title=Denoised");
setBatchMode(true);
run("Duplicate...", "title=pixels");
if (bitDepth==24) run("8-bit");

setThreshold(255, 255);
run("Threshold", "thresholded remaining");

//---
// if you want to denoise small clusters of pixels, rather than single pixels,
// then comment the following 5 lines, but be aware that the average
// or median will not be correct as other pixels in the cluster may
// contribute to the corrected value:
run("Duplicate...", "title=non-single");
run("Particles8 ", "white show=Particles filter minimum=2 maximum=999999
overwrite");
imageCalculator("Subtract", "pixels","non-single");
selectWindow("non-single");
close();
//---

selectWindow("Denoised");
run("Duplicate...", "title=median");

// use average of the 8 neighbours
run("Convolve...", "text1=[1 1 1 1 0 1 1 1 1] normalize");

// use median of the 3x3 neighbourhood
//run("Median...", "radius=1");

if (bitDepth==24){
  selectWindow("pixels");
  run("RGB Color");
}

imageCalculator("AND create", "pixels","median");
imageCalculator("Subtract", "Denoised","pixels");
imageCalculator("Add", "Denoised","Result of pixels");
selectWindow("median");
close();
selectWindow("Result of pixels");
close();
selectWindow("pixels");
close();
setBatchMode(false);
//-------------------->8--------------------------