Community
cancel
Showing results for 
Search instead for 
Did you mean: 
ulterior
Beginner
93 Views

sharpen filter crash

Hi, I am puzzled by sharpen filter crash, I must be doing something wrong, can anybody point me my err?

I am trying to sharpen 24 bit image and receive access violation crash...

IppiSize srcSize = {SHARPEN_AREA_WIDTH, SHARPEN_AREA_HEIGHT};
const int bitcount = 24;
int srcStep = (CANVAS_WIDTH * (bitcount / 8) + 3) & ~3;
int dstStep = (CANVAS_HEIGHT * (bitcount / 8) + 3) & ~3;

IppStatus status = ippiFilterSharpen_8u_C3R( srcBuffer, srcStep, dstBuffer, dstStep, srcSize );


//was trying to use anchor point "data+srcStep+1" to no avail too and srcSize is SMALLER than src buffer size

ippiMirror_8u_C3IR(srcBuffer, srcStep, srcSize, ippAxsHorizontal); //<-- with the settings above works correct



thanks in advance
0 Kudos
4 Replies
Ying_H_Intel
Employee
93 Views

Hello,

Could you attach a piece of code to show how the src buffer or dst buffer are allocated? and What is the value in CANVAS_HEIGHT?

The line int dstStep = (CANVAS_HEIGHT * (bitcount / 8) + 3) & ~3; may be the root cause.

As thearticle How to Use the IPP Image Filter Function, the parameter stepBytes:
it is the distance in bytes of imagerow.It depends on your array memory layout and datatype.In most of case,it isequal to the image Width*sizeof(datatype)*Channel or 4-bytes aligned: (image Width*sizeof(datatype)*Channel+3)&~3. Sohere it may notbethe CANVAS_HEIGHT.

(If you src buffer and dst bufferhave same size, the dstStep canuse srcStep as replacement. like ippiMirror_8u_C3IR does.)

Regards,
Ying
ulterior
Beginner
93 Views

Hi Ying, thanks for reply

my srcBuffer and dstBuffer is not of the same size ( dstBuffer is 90deg rotated srcBuffer ), therefore I calculate different stepsizes for the transformation. Buffers are created as Dib section:

srcBuffer( CANVAS_WIDTH, CANVAS_HEIGHT )
dstBuffer( CANVAS_HEIGHT, CANVAS_WIDTH ) and created as windows DIB

here are my constants

SHARPEN_AREA_WIDTH 720
SHARPEN_AREA_HEIGHT 480

CANVAS_WIDTH SHARPEN_AREA_WIDTH*2
CANVAS_HEIGHT SHARPEN_AREA_HEIGHT*2

I am quite sure my srcStep and dstStep are correct, because mirror function works flawlessly on the buffers
Ying_H_Intel
Employee
93 Views

Hi Ulterior,

I see. Thenlet's the next fact: filter border processing. What is the "data" definition? does it srcBuffer+srcStep+1?

The kernel size of sharping filter is3x3, it isok toshift the src Pointer to(1,1) pixel.But theexpected may besrcBuffer+srcStep+3 (3 chanel image).

Here is a small code for your reference,



#include "stdafx.h"
#include "ipp.h"
#include
#include


int _tmain(int argc, _TCHAR* argv[])
{

int srcStepBytes,dstStepBytes;
Ipp8u * pDst;
Ipp8u * pSrc;

int WIDTH=720;
int HEIGHT=480;
IppiSize roiSize={WIDTH,HEIGHT};
int CANVAS_WIDTH= WIDTH*2;
int CANVAS_HEIGHT= HEIGHT*2;

Ipp8u ONE[3]={100,100,100};
Ipp8u ZERO[3]={0,0,0};
//IppiSize roiBorderSize={roiSize.width+4,roiSize.height+4};

ippStaticInit();

pSrc=ippiMalloc_8u_C3(CANVAS_WIDTH, CANVAS_HEIGHT,&srcStepBytes);
ippiSet_8u_C3R(ONE, pSrc, srcStepBytes, roiSize );//roiBorderSize

pDst=ippiMalloc_8u_C3(CANVAS_HEIGHT,CANVAS_WIDTH,&dstStepBytes);
ippiSet_8u_C3R(ZERO, pDst, dstStepBytes, roiSize);

// Print the version of ipp being used
const IppLibraryVersion* lib = ippiGetLibVersion();
printf("%s %s %d.%d.%d.%d\n", lib->Name, lib->Version,lib->major, lib->minor, lib->majorBuild, lib->build);


IppStatus s ;
s = ippiFilterSharpen_8u_C3R( pSrc+srcStepBytes+3, srcStepBytes, pDst, dstStepBytes, roiSize );
printf("%s\n", ippGetStatusString(s));
ippiFree( pSrc );
ippiFree( pDst );
return 0;

}

the output is like
ippip8-7.0.dll+ 7.0 beta build 183.15 7.0.183.990 (I install IPP7.0 beta on my test machine)
ippStsNoErr: No error, it's OK

Regards,
Ying

ulterior
Beginner
93 Views

Hi Ying, thanks, my problem was trying to use anchor point "data+srcStep+1"

it should have been data+srcStep+(bitcount/8)

Best Regards, Leo
Reply