wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni (Operator)

Name

wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni — Image restoration by Wiener filtering.

Signature

wiener_filter_ni(Image, Psf, NoiseRegion : RestoredImage : MaskWidth, MaskHeight : )

Herror wiener_filter_ni(const Hobject Image, const Hobject Psf, const Hobject NoiseRegion, Hobject* RestoredImage, const Hlong MaskWidth, const Hlong MaskHeight)

Herror T_wiener_filter_ni(const Hobject Image, const Hobject Psf, const Hobject NoiseRegion, Hobject* RestoredImage, const Htuple MaskWidth, const Htuple MaskHeight)

void WienerFilterNi(const HObject& Image, const HObject& Psf, const HObject& NoiseRegion, HObject* RestoredImage, const HTuple& MaskWidth, const HTuple& MaskHeight)

HImage HImage::WienerFilterNi(const HImage& Psf, const HRegion& NoiseRegion, Hlong MaskWidth, Hlong MaskHeight) const

static void HOperatorSet.WienerFilterNi(HObject image, HObject psf, HObject noiseRegion, out HObject restoredImage, HTuple maskWidth, HTuple maskHeight)

HImage HImage.WienerFilterNi(HImage psf, HRegion noiseRegion, int maskWidth, int maskHeight)

def wiener_filter_ni(image: HObject, psf: HObject, noise_region: HObject, mask_width: int, mask_height: int) -> HObject

Description

wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni (ni = noise-estimation integrated) produces an estimate of the original image (= image without noise and blurring) by minimizing the mean square error between estimated and original image. wiener_filterwiener_filterWienerFilterWienerFilterwiener_filter can be used to restore images corrupted by noise and/or blurring (e.g., motion blur, atmospheric turbulence or out-of-focus blur). Method and realization of this restoration technique bases on the following model: The corrupted image is interpreted as the output of a (disturbed) linear system. Functionality of a linear system is determined by its specific impulse response. So the convolution of original image and impulse response results in the corrupted image. The specific impulse response describes image acquisition and the occurred degradations. In the presence of additive noise an additional noise term must be considered. So the corrupted image can be modeled as the result of [convolution(impulse_response,original_image)] + noise_term The noise term encloses two different terms describing image-dependent and image-independent noise. According to this model, two terms must be known for restoration by Wiener filtering:

  1. degradation-specific impulse response

  2. noise term

wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni estimates the noise term as follows: The user defines a region that is suitable for noise estimation within the image (homogeneous as possible, as edges or textures aggravate noise estimation). After smoothing within this region by an (unweighted) median filter and subtracting smoothed version from unsmoothed, the average noise amplitude of the region is processed within wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni. This amplitude together with the average gray value within the region allows estimating the quotient of the power spectral densities of noise and original image (in contrast to wiener_filterwiener_filterWienerFilterWienerFilterwiener_filter wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni assumes a rather constant quotient within the whole image). The user can define width and height of the rectangular (median-)filter mask to influence the noise estimation (MaskWidthMaskWidthMaskWidthmaskWidthmask_width, MaskHeightMaskHeightMaskHeightmaskHeightmask_height). wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni needs further the impulse response that describes the specific degradation. This impulse response (represented in spatial domain) must fit into an image of HALCON image type real. There exist two HALCON-operators for generation of an impulse response for motion blur and out-of-focus (see gen_psf_motiongen_psf_motionGenPsfMotionGenPsfMotiongen_psf_motion, gen_psf_defocusgen_psf_defocusGenPsfDefocusGenPsfDefocusgen_psf_defocus). The representation of the impulse response presumes the origin in the upper left corner. This results in the following disposition of an NxM sized image:

wiener_filterwiener_filterWienerFilterWienerFilterwiener_filter works as follows:

The result image has got image type real.

Attention

PsfPsfPsfpsfpsf must be of image type real and conform to ImageImageImageimageimage in width and height. The Region used for noise estimation must lie completely within the image. If MaskWidthMaskWidthMaskWidthmaskWidthmask_width or MaskHeightMaskHeightMaskHeightmaskHeightmask_height is an even number, it is replaced by the next higher odd number (this allows the unique extraction of the center of the filter mask). Width/height of the mask may not exceed the image width/height or be less than null.

Execution Information

Parameters

ImageImageImageimageimage (input_object)  (multichannel-)image objectHImageHObjectHObjectHobject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)

Corrupted image.

PsfPsfPsfpsfpsf (input_object)  (multichannel-)image objectHImageHObjectHObjectHobject (real)

impulse response (PSF) of degradation (in spatial domain).

NoiseRegionNoiseRegionNoiseRegionnoiseRegionnoise_region (input_object)  region(-array) objectHRegionHObjectHObjectHobject

Region for noise estimation.

RestoredImageRestoredImageRestoredImagerestoredImagerestored_image (output_object)  image objectHImageHObjectHObjectHobject * (real)

Restored image.

MaskWidthMaskWidthMaskWidthmaskWidthmask_width (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of filter mask.

Default: 3

Suggested values: 3, 5, 7, 9

Value range: 0 ≤ MaskWidth MaskWidth MaskWidth maskWidth mask_width ≤ width(Image)

MaskHeightMaskHeightMaskHeightmaskHeightmask_height (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of filter mask.

Default: 3

Suggested values: 3, 5, 7, 9

Value range: 0 ≤ MaskHeight MaskHeight MaskHeight maskHeight mask_height ≤ height(Image)

Example (C)

/* Restoration of a noisy image (size=256x256), that was blurred by motion*/
Hobject object;
Hobject restored;
Hobject psf;
Hobject noise_region;
/* 1. Generate a Point-Spread-Function for a motion-blur with       */
/*    parameter a=10 and direction of the x-axis                    */
gen_psf_motion(&psf,256,256,10,0,3);
/* 2. Segmentation of a region for the noise-estimation             */
open_window(0,0,256,256,0,"visible",&WindowHandle);
disp_image(object,WindowHandle);
draw_region(&noise_region,draw_region);
/* 3. Wiener-filtering                                              */
wiener_filter_ni(object,psf,noise_region,&restored,3,3);

Result

wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni returns 2 ( H_MSG_TRUE) if all parameters are correct. If the input is empty wiener_filter_niwiener_filter_niWienerFilterNiWienerFilterNiwiener_filter_ni returns with an error message.

Possible Predecessors

gen_psf_motiongen_psf_motionGenPsfMotionGenPsfMotiongen_psf_motion, simulate_motionsimulate_motionSimulateMotionSimulateMotionsimulate_motion, simulate_defocussimulate_defocusSimulateDefocusSimulateDefocussimulate_defocus, gen_psf_defocusgen_psf_defocusGenPsfDefocusGenPsfDefocusgen_psf_defocus, optimize_fft_speedoptimize_fft_speedOptimizeFftSpeedOptimizeFftSpeedoptimize_fft_speed

Alternatives

wiener_filterwiener_filterWienerFilterWienerFilterwiener_filter

See also

simulate_motionsimulate_motionSimulateMotionSimulateMotionsimulate_motion, gen_psf_motiongen_psf_motionGenPsfMotionGenPsfMotiongen_psf_motion, simulate_defocussimulate_defocusSimulateDefocusSimulateDefocussimulate_defocus, gen_psf_defocusgen_psf_defocusGenPsfDefocusGenPsfDefocusgen_psf_defocus

References

M. Lückenhaus:“Grundlagen des Wiener-Filters und seine Anwendung in der Bildanalyse”; Diplomarbeit; Technische Universität München, Institut für Informatik; Lehrstuhl Prof. Radig; 1995
Azriel Rosenfeld, Avinash C. Kak: Digital Picture Processing, Computer Science and Aplied Mathematics, Academic Press New York/San Francisco/London 1982

Module

Foundation