を読んだ後、私はOpenCVの中で私のカラー(3チャンネル)の画像からヒストグラムを取得しようとしているが、私はこのようcalcHistヒストグラムを行うたびにしています:未処理の例外(calcHistで作成した)ヒストグラム
//int histSize[3];
//float hranges[2];
//const float* ranges[3];
//int channels[3];
ColorHistogram::ColorHistogram()
{
// Prepare arguments for a color histogram
histSize[0]= histSize[1]= histSize[2]= 256;
hranges[0]= 0.0; // BRG range
hranges[1]= 255.0;
ranges[0]= hranges; // all channels have the same range
ranges[1]= hranges;
ranges[2]= hranges;
channels[0]= 0; // the three channels
channels[1]= 1;
channels[2]= 2;
}
cv::MatND ColorHistogram::getHistogram(const cv::Mat &image)
{
cv::MatND hist;
// Compute histogram
cv::calcHist(&image,
1, // histogram of 1 image only
channels, // the channel used
cv::Mat(), // no mask is used
hist, // the resulting histogram
3, // it is a 3D histogram
histSize, // number of bins
ranges // pixel value range
);
return hist;
}
結果をたとえばcv::minMaxLoc
に入力しようとすると、処理されない例外が発生します。
OpenCV Error: Assertion failed (img.dims <= 2) in unknown function, file C:\slave\WinInstallerMegaPack\src\opencv\modules\core\src\stat.cpp, line 788
と私のimage
のdims = 2