- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I am trying to use ippiHistogram. The problem is - the last (256) byte of histogram result buffer is not filled by ippiHistogram_8u_C1R.
I have tried to use ippiHistogramInit instead of ippiHistogramUniformInit - the result is the same.
Previously I used iplComputeHisto function - it had worked correctly.
For example iplComputeHisto returns pHistVec[255] = 1226, but ippiHistogram_8u_C1R returns pHistVec[255] = 1393896807
I use IPPI version 9 Update 1.
Please, explain, how can I get last histogram value? Thank you!
Here is the code:
IppiSize roi = {image->width, image->height};
int nChannels = image->nChannels;
const int histLen = 255;
int nLevels[] = { histLen+1 };
Ipp32f lowerLevel[] = {0};
Ipp32f upperLevel[] = {255};
Ipp32f pLevels[histLen+1], *ppLevels[1];
int sizeHistObj = 0;
int sizeBuffer = 0;
IppiHistogramSpec* pHistObj = NULL;
Ipp8u* pBuffer = NULL;
Ipp32u pHistVec[histLen + 1];
bool errorInCycle = false;
IppStatus sts = ippiHistogramGetBufferSize(ipp8u, roi, nLevels, nChannels, 0, &sizeHistObj, &sizeBuffer);
if(sts != ippStsNoErr)
{
return;
}
pHistObj = (IppiHistogramSpec*)ippsMalloc_8u(sizeHistObj);
if(pHistObj == NULL)
{
return;
}
pBuffer = (Ipp8u*)ippsMalloc_8u(sizeBuffer);
if(pHistObj == NULL)
{
ippsFree( pHistObj );
return;
}
sts = ippiHistogramUniformInit(ipp8u, lowerLevel, upperLevel, nLevels, nChannels, pHistObj);
if(sts != ippStsNoErr)
{
ippsFree( pHistObj );
ippsFree( pBuffer );
return;
}
sts = ippiHistogram_8u_C1R((const Ipp8u *) image->imageData, image->widthStep, roi, pHistVec, pHistObj, pBuffer);
if(sts != ippStsNoErr)
{
ippsFree( pHistObj );
ippsFree( pBuffer );
return;
}
std::stringstream ssTemp;
ssTemp << "Hist: ";
for(int i=0; i < 256; i++)
{
ssTemp << i << " = " << pHistVec << ",";
}
OutputDebugString((char *)ssTemp.str().c_str());
Kind regards
Dmitry
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,I too am getting sizeBuffer = 0 from ippiHistogramGetBufferSize
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The API is nuts (or at least counter-intuitive). For 256 histogram entries, you have to pass 257 as the nLevels parameter of ippiHistogramUniformInit. This is for analogy with non-uniform histograms, but very tricky. The sample code in the documentation is wrong too.
Regards,
Adriaan van Os
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page