MF_deconvolve MD_deconvolve ME_deconvolve
Functionspatial deconvolution, edge sharpening
Syntax C/C++#include <MFstd.h>
void MF_deconvolve( fMatrix Y, fMatrix Flt, fMatrix X, fMatrix Rsp, ui ht, ui len );
C++ MatObj#include <OptiVec.h>
void matrix<T>::deconvolve( matrix<T> Flt, const matrix<T>& MX, const matrix<T> Rsp);
void matrix<T>::deconvolve( matrix<T>* Flt, const matrix<T>& MX, const matrix<T> Rsp);
Pascal/Delphiuses MFstd;
procedure MF_deconvolve( MY, MFlt, MX, MRsp:fMatrix; ht, len:UIntSize );
DescriptionMX is assumed to be the result of a convolution of some "true" profile with the response function MRsp; a deconvolution is attempted and stored in MY. A filter MFlt is also calculated; if more than one matrix is to be deconvolved with the same MRsp, use MF_deconvolve only once and use the filter MFlt thus obtained to deconvolve other matrices by calling MF_filter. The response has to be stored in the wrap-around order described above for MF_convolve.

As for MF_convolve, MX, MY, MRsp, and MFlt must all be of the same dimensions, which have to be integer powers of 2. MX may be overwritten by MY, MRsp may be overwritten by MFlt, but MX and MFlt as well as MY and MRsp have to be distinct from each other.

Mathematically, MFlt is the inverse of the Fourier transform of MRsp. If the Fourier transform of MRsp contains elements equal to zero, all information is lost for the respective frequency and no reconstruction is possible. The best one can do in this case is to accept this loss and to deconvolve only up to those frequencies where still something is left to be reconstructed.
You are therefore advised not to use this function blindly but rather to inspect the Fourier transform of MRsp and decide what to do on the basis of your specific application. If you wish to use this function nevertheless, you may rely on the automatic editing of the filter, built into MF_deconvolve. Thereby, MFlt is set to zero (instead of infinity) at those frequences where all information has been lost. You may set the threshold for this implicit editing by VF_setRspEdit. In order to retrieve the threshold actually set, use VF_getRspEdit. (These two functions are shared between the one- and two-dimensional FFT functions and described in FUNCREF.HTM.)

This deconvolution is based on the implicit assumption that MX is periodic; if this is not the case, see the description of VF_convolve about how to avoid end effects.

Error handlingIf either len or ht is not a power of 2, VF_FFT (on which MF_deconvolve is based) complains "Size must be an integer power of 2" and the program is aborted.
If, by VF_setRspEdit, you specified Trunc.Re = Trunc.Im = 0, SING errors may occur that are handled by setting MFlt to ±HUGE_VAL at the respective frequency. During multiplication with the transform of MX, this may lead to unhandled floating-point overflow errors (in case your guess of MRsp was wrong and there is some information left at the frequencies where you thought it was not).
About special versions with the prefixes MFl_ and MFs_, consult chapter 4.8 of http://www.optivec.com/vecfuncs/.
See alsoMF_convolve,   MF_FFT,   chapter 12

MatrixLib Table of Contents  OptiVec home