Community
cancel
Showing results for 
Search instead for 
Did you mean: 
sid1
Beginner
110 Views

ipprFilter access violation (wrong usage?)

Jump to solution
I was happy to realize that the recent releases introduced some basic filtering of 3D volumes, but unfortunately I'm trying to use ipprFilter to do a simple filtering with a summation kernel on a neighborhood of 3x3x3 and I get an access violation.

What I basically did was to allocate a large 'volume' (with ippsMalloc_16s) that includes suitable margins in all dimensions:
16 voxels on each end of each row (for the original 512x512xN data to remain aligned to 32 bytes)
1 extra row on each end of each plane
1 extra plane on each end of the entire volume

The entire 'volume' was reset with ippsZero and the original data was copied row by row with extra care for the margins.

I then defined Ipp16s **pSrc = new Ipp16s*, an array of N pointers to Ipp16s, as required by ipprFilter, and initialized each element to point to the correct offset within each plane of the volume (for all but the first and last planes that serve as margins).

Did the same for pDst.

Finally, I calculated the size of the buffer required for ipprFilter, using ipprFilterGetBufSize and allocated filtAuxBuf, an Ipp8u array of that size.

The call to ipprFilter was as follows:
IppStatus sts =
ipprFilter_16s_C1PV(pSrc, nVoxelsPerRowWithMargins*sizeof(short),
(const Ipp16s**)pDst, nVoxelsPerRowWithMargins*sizeof(short),
dstVolume, pKernel, kernelVolume, anchor, 1, filtAuxBuf);
where:
dstVolume = {512, 512, N}
pKernel = {1, 1, 1, 1, 1, 1, 1, 1, 1}
kernelVolume {3, 3, 3}
anchor = {1, 1, 1}

Note that I had to perform a c-style cast of pDst to (const Ipp16s**) or else the compilation fails ("Conversion loses qualifiers"). That for itself is a bit troubling.

Does anybody have an experience with ipprFilter?
Does anybody have a code snippet that shows correct usage?

Please advise.
0 Kudos
1 Solution
Yuri_Tikhomirov__Int
New Contributor I
110 Views

Hi Sid,

You will find a working exampleof function usage in the attached file test_3df.cpp.

You need to initialize all kernel values (3*3*3 in your case) and correctly to allocate memory for volumes(not on a stack).

Thanks,
Beg

View solution in original post

4 Replies
sid1
Beginner
110 Views
Quoting - sid1
dstVolume = {512, 512, N}
>>> pKernel = {1, 1, 1, 1, 1, 1, 1, 1, 1}
kernelVolume {3, 3, 3}
anchor = {1, 1, 1}
Even after modifying the kernel to have 27 elements(!), the call still performs an access violation.
Yuri_Tikhomirov__Int
New Contributor I
111 Views

Hi Sid,

You will find a working exampleof function usage in the attached file test_3df.cpp.

You need to initialize all kernel values (3*3*3 in your case) and correctly to allocate memory for volumes(not on a stack).

Thanks,
Beg

View solution in original post

sid1
Beginner
110 Views

Hi Sid,

You will find a working exampleof function usage in the attached file test_3df.cpp.

You need to initialize all kernel values (3*3*3 in your case) and correctly to allocate memory for volumes(not on a stack).

Thanks,
Beg

Yuri,

Thanks for the example! Regretfully, I already converted my code to use successive IPPI calls, but I will save your code for rainy days.
The main difference is that you allocated plane by plane where I allocated the entire volume at once and initialized pointers to each plane.
In my next attempt I would most certainly follow your guidlines.

Thanks,
Sid
JD
Beginner
110 Views
Hi Yuri,

Have you tried your code for different filter kernel sizes? If, for example, I set:
#define kwid 9

I get an error in the filter output and also a run-time error when deallocating the memory.

Do you know if this is a bug in your implementation of in the filter routine, ipprFilter_16s_C1PV, itself?

Thanks,

Jonathan.
Reply