Ask Your Question

Revision history [back]

Exception for normalize 3D histogram (minMaxLoc)

Hi ,

I want to use normalize 3d histogram and I have got an exception :

OpenCV Error: Assertion failed (_img.dims() <= 2) in cv::minMaxLoc, file G:\Lib\opencv\modules\core\src\stat.cpp, line 2408

Does it mean that normalize does not accept 3D Mat?

My program is (Opencv 3.1-dev VS2015):

    Mat m = imread("f:/lib/opencv/samples/data/baboon.jpg", CV_LOAD_IMAGE_ANYCOLOR);

    float hRange[] = { 0, 256 };
    const float* etendu[] = { hRange, hRange,hRange };
    int hBins = 30;
    int tailleHist[] = { hBins, hBins, hBins };
    int canaux[] = { 0, 2,1 };
    cv::Mat histogramme;
    cv::calcHist(&m, 1, canaux, Mat(), histogramme, 2, tailleHist, etendu, true, false);
    normalize(histogramme, histogramme, 0, 255, cv::NormTypes::NORM_MINMAX, -1, cv::Mat());
    cv::calcHist(&m, 1, canaux, Mat(), histogramme, 3, tailleHist, etendu, true, false);
    normalize(histogramme, histogramme, 0, 255, cv::NormTypes::NORM_MINMAX, -1, cv::Mat());// EXCEPTION HERE
    waitKey();