/********************************************************
* *
* R e m o v e X r a y F i l t e r *
* *
* ©bs, FELMI/ZfE, Graz, 08/2006 *
* *
********************************************************/
/* description:
created: 10.08.2006
versions: 1.0
author: Bernhard Schaffer (bernhard.schaffer AT felmi-zfe.at)
*/
/* Instructions:
The function removes X-ray spikes (very bright/dark spots) in images by
applying a median filter (of given type & size) and comparing the original
image with the filtered one. If the difference is larger than a certain limit
(given as multiplicative factor of the standard deviation in of the difference
image), the pixel value is replaced by the mean value. Else it remains unchanged.
Works well and fast with TYPE=3 SIZE=1
For 1D-graphs use the TYPE=0 !
This function should work similar to the Volume/Remove X-rays menu-command of Gatan,
but I do not know what this packages does exactly.
*/
image RemoveXrayFilter(image IN,number MTyp,number MSize,number Sigma,number OPTcount, number &FOUND)
{
image median = MedianFilter(IN,MTyp,MSize)
image diff = abs(in-median)
number meandiff = Sigma*SQRT(variance(diff))
image out = tert(diff>meanDiff,median,in)
If (OPTcount) FOUND = sum(!!(out-in))
return out
}