Quantcast
Channel: Intel® Software - Intel® Integrated Performance Primitives
Viewing all articles
Browse latest Browse all 1489

DeconvLR

$
0
0

Hi,

I've checked forum posts regarding Lucy-Richardson deconvolution, but I still can acquire "reasonable" results.
An input image is 3-channels RGB image (output image is the same with same dimensions), so I must first convert input image
to 32f, run deconvolution and then convert resultant 32f image to 8u output image.
Here is the code that I use to perform LR Deconvolution:

---------------------------------------------------------
int ippProcess::DeconvolveLR(ippImage<ippRGB> *srcImage, ippImage<ippRGB> *dstImage, TRect *roiRect,
int kernelSize, float threshold, int numIter)
{
// calculate srcStep/dstStep/roiSize with respect to roiRect
prepareData(srcImage, dstImage, roiRect);
IppStatus status;
Ipp32f thr = threshold /255.0;
IppiSize maxRoi;
maxRoi.width = roiSize.width + kernelSize;
maxRoi.height = roiSize.height + kernelSize;
IppiDeconvLR_32f_C3R *pDeconvLR = 0;
int pSize;
status = ippiDeconvLRGetSize_32f(3, kernelSize, maxRoi, &pSize);
if (status)
return status;
pDeconvLR = (IppiDeconvLR_32f_C3R *)ippsMalloc_32f(pSize);
Ipp32f *kernel = new Ipp32f[kernelSize*kernelSize];
// fill the PSF with ones
for (int i = 0; i < kernelSize*kernelSize; i++)
kernel[i] = 1;
status = ippiDeconvLRInit_32f_C3R(pDeconvLR, kernel, kernelSize, maxRoi, thr);
if (status)
{
delete []kernel;
ippsFree(pDeconvLR);
return status;
}
int interStepIn, interStepOut;
Ipp32f *interImageIn = ippiMalloc_32f_C3(maxRoi.width, maxRoi.height, &interStepIn);
Ipp32f *interImageOut = ippiMalloc_32f_C3(roiSize.width, roiSize.height, &interStepOut);
//
status = ippiConvert_8u32f_C3R(pSrc, srcStep, interImageIn, interStepIn, roiSize); // convert forward
status = ippiDeconvLR_32f_C3R(interImageIn, interStepIn, interImageOut, interStepOut, roiSize, numIter, pDeconvLR);
if (!status)
ippiConvert_32f8u_C3R(interImageOut, interStepOut, pDst, dstStep, roiSize, ippRndNear); // convert backward
ippsFree(pDeconvLR);
ippiFree(interImageIn);
ippiFree(interImageOut);
delete []kernel;
return status;
}
---------------------------------------------

However, resulting image has some strange artifacts on the image border. Also, for larger kernel sizes and larger iterations number (>= 5)
output image looks embossed and the effect of color channels shifting arises.
From the documentation, it's not clear does DeconvLR operate on scaled f32 images (I've tried scaling as well), what is the range of threshold parameter and how the input image should be "placed" inside maxRoi.

If someone can detect the error in my code, it would be helpful.
TIA


Viewing all articles
Browse latest Browse all 1489


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>