Link Copied
[cpp]For (1) and (2) we have supporting functionality (ippSP functions are not suitable for that as Pack2D format doesnt correspond to Pack 1D): /* ///////////////////////////////////////////////////////////////////////////// // Name: ippiPackToCplxExtend // // Purpose: Converts an image in RCPack2D format to a complex data image. // // Returns: // ippStsNoErr No errors // ippStsNullPtrErr pSrc == NULL, or pDst == NULL // ippStsStepErr One of the step values is less zero or negative // ippStsSizeErr The srcSize has a field with zero or negative value // // Parameters: // pSrc Pointer to the source image data (point to pixel (0,0)) // srcSize Size of the source image // srcStep Step through the source image // pDst Pointer to the destination image // dstStep Step through the destination image // Notes: */ IPPAPI (IppStatus, ippiPackToCplxExtend_32f32fc_C1R, (const Ipp32f* pSrc, IppiSize srcSize, int srcStep, Ipp32fc* pDst, int dstStep )) /* ///////////////////////////////////////////////////////////////////////////// // Name: ippiCplxExtendToPack // // Purpose: Converts an image in complex data format to RCPack2D image. // // Returns: // ippStsNoErr No errors // ippStsNullPtrErr pSrc == NULL, or pDst == NULL // ippStsStepErr One of the step values is less zero or negative // ippStsSizeErr The srcSize has a field with zero or negative value // // Parameters: // pSrc Pointer to the source image data (point to pixel (0,0)) // srcSize Size of the source image // srcStep Step through the source image // pDst Pointer to the destination image // dstStep Step through the destination image // Notes: */ IPPAPI(IppStatus,ippiCplxExtendToPack_32fc32f_C1R,(const Ipp32fc* pSrc, int srcStep, IppiSize srcSize, Ipp32f* pDst, int dstStep )) After numerator/denominator conversion to cplx format ippiDiv_32fc can be used and then conversion back to Pack format. [/cpp]
[cpp]For (1) and (2) we have supporting functionality (ippSP functions are not suitable for that as Pack2D format doesnt correspond to Pack 1D):
/* /////////////////////////////////////////////////////////////////////////////
// Name: ippiPackToCplxExtend
//
// Purpose: Converts an image in RCPack2D format to a complex data image.
/* /////////////////////////////////////////////////////////////////////////////
// Name: ippiCplxExtendToPack
//
// Purpose: Converts an image in complex data format to RCPack2D image.
After numerator/denominator conversion to cplx format ippiDiv_32fc can be used and then conversion back to Pack format.
[/cpp]
Hi Koen,
Sorry for silence on this thread for a long time, I would like to know what value you like to have for zero/zero 1, 0 or NaN?
Regards,
Naveen Gv
Hi all,
as this is not the first request for such kind functionality, use the next reference code for division in Pack format (this function performs division of Packed FFT output by its Magnitude - the corresponding IPP function will be available in the next IPP release):
#include
///////////////////////////////////////////////////////////////////////////// */
/* Name: NormalizePack_32f_C1R
// Purpose: Divides pixel values of an image in RCPack2D format
// by its magnitude values and store the results
// in a destination image in RCPack2D format
// Parameters:
// pSrc Pointer to the source image in RCPack2D format
// srcStep Step through the source image
// pDst Pointer to the destination image in RCPack2D format
// dstStep Step through the destination image
// roiSize Size of the source and destination ROI
// Returns:
// ippStsNoErr No errors
// ippStsNullPtrErr One of the pointers is NULL
// ippStsStepErr One of the step values is zero or negative
// ippStsSizeErr The roiSize has a field with negative or zero value
// Notes:
//double precision is used for magnitude calculation
//if magnitude==0, then normalized value is set to 0
//thereare no any special checks for NaNor Inf
*/
#define MAGNREC(x) x = (!x) ? 0 : (1./sqrt(x))
static void ownCalcMagnRec_OneCol (
Ipp32f *src0, Ipp32f *src1, int sline,
Ipp32f *dst0, Ipp32f *dst1, int dline,
int length, int flag)
{
int i;
float re, im;
double val;
for (i = 1; i < length; i += 2) {
re = *src0; im = *src1;
val = re * re + im * im;
MAGNREC(val);
*dst0 = (float)(re * val);
*dst1 = (float)(im * val);
src0 = (Ipp32f*)((Ipp8u*)src0 + sline);
src1 = (Ipp32f*)((Ipp8u*)src1 + sline);
dst0 = (Ipp32f*)((Ipp8u*)dst0 + dline);
dst1 = (Ipp32f*)((Ipp8u*)dst1 + dline);
}
if (!flag) dst0[0] = (src0[0] >= 0) ? 1.f : -1.f;
}
static void ownCalcMagnRec_32f_C1 (
Ipp32fc *src, Ipp32fc *dst, int length)
{
int i;
float re, im;
double val;
for (i = 0; i < length; i ++) {
re = src.re;
im = src.im;
val = re * re + im * im;
MAGNREC(val);
dst.re = (float)(re * val);
dst.im = (float)(im * val);
}
}
IppStatus NormalizePack_32f_C1R (
const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep,
IppiSize roiSize)
{
int dw, dh, w, h, j;
Ipp32f *src0, *src1, *dst0, *dst1;
Ipp32fc *sfc, *dfc;
dw = roiSize.width;
dh = roiSize.height;
w = (dw & 1) ? 1 : 0;
h = (dh & 1) ? 1 : 0;
/* 1st column */
pDst[0] = (pSrc[0] >= 0) ? 1.f : -1.f;
src0 = (Ipp32f*)((Ipp8u*)pSrc + srcStep);
dst0 = (Ipp32f*)((Ipp8u*)pDst + dstStep);
src1 = (Ipp32f*)((Ipp8u*)src0 + srcStep);
dst1 = (Ipp32f*)((Ipp8u*)dst0 + dstStep);
ownCalcMagnRec_OneCol (
src0, src1, srcStep+srcStep,
dst0, dst1, dstStep+dstStep,
dh-1, h);
/* last column */
if (!w) {
pDst[dw-1] = (pSrc[dw-1] >= 0) ? 1.f : -1.f;
src0 = (Ipp32f*)((Ipp8u*)pSrc + srcStep);
dst0 = (Ipp32f*)((Ipp8u*)pDst + dstStep);
src1 = (Ipp32f*)((Ipp8u*)src0 + srcStep);
dst1 = (Ipp32f*)((Ipp8u*)dst0 + dstStep);
ownCalcMagnRec_OneCol (
src0+dw-1, src1+dw-1, srcStep+srcStep,
dst0+dw-1, dst1+dw-1, dstStep+dstStep,
dh-1, h);
}
/* region of complex numbers */
dw = (dw - 1) >> 1;
sfc = (Ipp32fc*)(pSrc + 1);
dfc = (Ipp32fc*)(pDst + 1);
for (j = 0; j < dh; j ++) {
ownCalcMagnRec_32f_C1(sfc, dfc, dw);
sfc = (Ipp32fc*)((Ipp8u*)sfc + srcStep);
dfc = (Ipp32fc*)((Ipp8u*)dfc + dstStep);
}
return ippStsNoErr;
}
regards,
Igor
For more complete information about compiler optimizations, see our Optimization Notice.