IPP with C# : RGB Image histogram : HELP!

IPP with C# : RGB Image histogram : HELP!

I'm using IPP with C#.

I can get a Histogram of an 8 bit (gray image) doing like this :

int [] histo = new int[256] ;
int [] levels = new int[256] ;

for (int i = 0 ; i < 256 ; i++){levels[i] = i ;}
fixed (int* phisto = histo, plevels = levels)
{
ip.ippiHistogramRange_8u_C1R((byte*)bmpsrcdata.Scan0, bmpsrcdata.Stride, roi, phisto, plevels ,256);
}


This works. But I want to generalise it on a colour image RGB using
ippiHistogram_8u_C3R function. I've tried everything without results.

Pleasehelp me giving me an example to show me how to do this ?
Thanks.
P.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,

you can try this

int[,] histo = new int[3,256];
int[,] levels = new int[3,256];
int[] Histo = {0,0,0}, Levels = {0,0,0}, N = {256,256,256};

for( int j=0; j<3; j++ )
{
for( int i=0; i<256; i++ )
{
levels[j,i]=i;
}
}

fixed( int* pH=histo, pL=levels, nLevels=N )
{
Histo[0]=(int)pH; Histo[1]=(int)(pH+256); Histo[2]=(int)(pH+512);

Levels[0]=(int)pL; Levels[1]=(int)(pL+256); Levels[2]=(int)(pL+512);

fixed( int* ph=Histo, pl=Levels )
{
int** pHisto=(int**)ph, pLevels=(int**)pl;
IppStatus st = ip.ippiHistogramRange_8u_C3R((byte*)bmpsrcdata.Scan0,bmpsrcdata.Stride,roi,pHisto,pLevels,nLevels);
}
}

Regards,
Vladimir

Great! It works. Thanks a lot for your help.

P.

Leave a Comment

Please sign in to add a comment. Not a member? Join today