Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

gpu::histEven delivers incorrect number of Pixels

Hi,

I am currently exploring the gpu OpenCV algorithms and recognized, that gpu::histEven might be buggy. gpu::histEven delivers the incorrect number of pixels when all bins are summed up, at least for certain images.

The following code delivers 1.536.000 pxls instead of 2.000.000 for an image of size 2000x1000. However if I change the image dimension to 1000x2000 I get the correct number of pixels.

gpu::calcHist works fine by the way. Am I doing something wrong, or is this a bug? I use OpenCV 2.4.9 and Visual Studio 2012 and my graphics card is a NVidia NVS 4200M.

Thanks in advance!

cv::gpu::GpuMat hist;
cv::gpu::GpuMat srcImg(2000,1000,CV_8U,cv::Scalar(127));
cv::gpu::GpuMat srcImg2(1000,2000,CV_8U,cv::Scalar(127));

cv::gpu::histEven(srcImg,hist,256,0,256);
cv::Mat tmp;
hist.download(tmp);
int sum=0;
for(int i=0; i<256;++i)
    sum +=tmp.at<int>(0,i);
std::cout << "Num Pxls GPU histEven 2000x1000: " << sum << std::endl;

cv::gpu::histEven(srcImg2,hist,256,0,256);
hist.download(tmp);
sum=0;
for(int i=0; i<256;++i)
    sum +=tmp.at<int>(0,i);
std::cout << "Num Pxls GPU histEven 1000x2000: " << sum << std::endl;