Community
cancel
Showing results for 
Search instead for 
Did you mean: 
FredrikHall
Beginner
131 Views

Basic ippiFilterGauss - strange image size results

Jump to solution

I am experimenting a bit with basic aspects of the built-in image filters. However I am observing some strange things for my small sample. The code below fails/crashes (Jaehna works fine though) but all works fine if I reduce size to 512. How can this be? It has been a looong time since I last wrote C/C++, so this may be a really basic error on my part...

My first thought was that perhaps the crashing was due not specififying a ROI, to prevent from filtering outside the input image. But that would not explain why things work for 512x512...

Any input would be most helpful!

IppiSize imgSize = {1024, 1024};
size_t size = imgSize.width*imgSize.height*1;
void* data = malloc(size);
Ipp8u dst[1024*1024];
memset(data, 0, size);
status = ippiImageJaehne_8u_C1R((Ipp8u*)data, imgSize.width, imgSize);
ippiFilterGauss_8u_C1R((Ipp8u*)data, imgSize.width, dst, imgSize.width, imgSize, ippMskSize5x5);

0 Kudos
1 Solution
matthieu_darbois
New Contributor III
131 Views

Hi,

There's a small error in the code you provided.

The last line should be

[cpp]ippiFilterGauss_8u_C1R(pStartPoint, srcStep, dst, dstStep, dstRoi, ippMskSize3x3);[/cpp]

Regards,

Matthieu

View solution in original post

6 Replies
Chao_Y_Intel
Employee
131 Views

Hello,

This looks an image border problem. Intel IPP image filtering functions assume that for each pixel being processed, adjacent pixels also exist:
http://www.intel.com/support/performancetools/libraries/ipp/sb/CS-022139.htm

When using 5x5 kernel, ippiFilterGauss_8u_C1R function needs to keep 2 lines in the image top/bottom/left/right

Thanks,
Chao

FredrikHall
Beginner
131 Views
Quoting - Chao Yu (Intel)

Hello,

This looks an image border problem. Intel IPP image filtering functions assume that for each pixel being processed, adjacent pixels also exist:
http://www.intel.com/support/performancetools/libraries/ipp/sb/CS-022139.htm

When using 5x5 kernel, ippiFilterGauss_8u_C1R function needs to keep 2 lines in the image top/bottom/left/right

Thanks,
Chao

But how come the 512x512 version works without extending or defining an ROI? It seems a bit unfortunate that the only code sample that is provided by Intel (Example 9-9) does not properly handle borders or ROI, if this is indeed needed!

FredrikHall
Beginner
131 Views

Following your suggestion that this is due to some kind of ROI/border restriction (that is not triggered for 512x512 image), I tried specifying a ROI. However I still have the same problems running the code below. Using a 3x3 fixed filter would correspond to using a ROI 1 px smaller around, and with anchor point of 1,1.

Any chance of getting help with a successfully running filter using ROI?

IppiSize imgSize = {1024, 1024};
size_t size = imgSize.width*imgSize.height;
int srcStep = imgSize.width * sizeof(Ipp8u);
Ipp8u* data = (Ipp8u*)malloc(size);
memset(data, 0, size);
ippiImageJaehne_8u_C1R(data, srcStep, imgSize);

IppiSize dstRoi = {1022, 1022};
int dstStep = dstRoi.width * sizeof(Ipp8u);
Ipp8u *pStartPoint;
pStartPoint = data + (1 * srcStep) + 1;
size_t dstSize = dstRoi.width*dstRoi.height;
Ipp8u* dst = (Ipp8u*)malloc(dstSize);
memset(dst, 0, dstSize);

ippiFilterGauss_8u_C1R(data, srcStep, dst, dstStep, dstRoi, ippMskSize3x3);

matthieu_darbois
New Contributor III
132 Views

Hi,

There's a small error in the code you provided.

The last line should be

[cpp]ippiFilterGauss_8u_C1R(pStartPoint, srcStep, dst, dstStep, dstRoi, ippMskSize3x3);[/cpp]

Regards,

Matthieu

View solution in original post

FredrikHall
Beginner
131 Views

Hi,

There's a small error in the code you provided.

The last line should be

[cpp]ippiFilterGauss_8u_C1R(pStartPoint, srcStep, dst, dstStep, dstRoi, ippMskSize3x3);[/cpp]

Regards,

Matthieu

Thanks a million! Stupid copy-paste error...

My next step is looking into replication, in order to process the full image, including the border. As I understand, the in-place version would allow me to do this without allocating a full new image, or have the original image be created using padding at that stage. Is this correct? If so, what kind of impact would this have on my performance? I can imagine the access patterns would be a bit more exotic for the border pixels...

matthieu_darbois
New Contributor III
131 Views

Hi again,

you could probably do something like this :

[cpp]IppiSize roiSize = {1024, 1024};
IppiSize imgSize = {1026, 1026};

   size_t size = imgSize.width*imgSize.height* sizeof(Ipp8u);
   int srcStep = imgSize.width * sizeof(Ipp8u);
   Ipp8u* data = (Ipp8u*)malloc(size);
   Ipp8u *pStartPoint;
   pStartPoint = data + (1 * srcStep) + 1;    ippiImageJaehne_8u_C1R(pStartPoint , srcStep, roiSize);
   ippiCopyReplicateBorder_8u_C1IR(pStartPoint , srcStep, roiSize, imgSize , 1, 1);
 
   int dstStep = dstRoi.width * sizeof(Ipp8u);
   
   size_t dstSize = roiSize.width*roiSize.height;
   Ipp8u* dst = (Ipp8u*)malloc(dstSize);   
   ippiFilterGauss_8u_C1R(data, srcStep, dst, dstStep, roiSize, ippMskSize3x3);[/cpp]

Also, you should consider allocating memory with ippiMalloc function to get properly aligned line buffers (Improves performance).

As for the overhead of allthis, I don't really know but I think it should be quite low.

Regards,

Matthieu

Reply