Ask Your Question
0

Can't get correct parameter format for cv::calcHist

asked 2018-04-17 00:54:38 -0600

open_ranger gravatar image

I'm trying to utilising calcHist with the fowllowing code.

int channels[]={0,1,2};
int histSize[]={25,25,25};
float range[]={0,256};
const float* ranges[]={range,range,range};
printf("Ranges: %4.1d\t Type name: %s\t\n",0,typeid(ranges).name());
reference=imread("/home/wxh/Desktop/Photo/reference.bmp ",IMREAD_UNCHANGED);
calcHist(&reference,1,channels,noArray(),hist,3,histSize,ranges,true,false)

and the complier gives me the error message

OpenCV Error: Assertion failed (j < nimages) in histPrepareImages, file /home/wxh/opencv-3.2.0/modules/imgproc/src/histogram.cpp, line 148
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/wxh/opencv-3.2.0/modules/imgproc/src/histogram.cpp:148: error: (-215) j < nimages in function histPrepareImages

Which part gone wrong?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-04-17 01:13:48 -0600

berak gravatar image

your image was not read correctly. please add a check:

reference=imread("/home/wxh/Desktop/Photo/reference.bmp ",IMREAD_UNCHANGED);
if (reference.empty()) {
    !!!
}
edit flag offensive delete link more

Comments

1

there is a extra space behind ".bmp"(+﹏+)~

open_ranger gravatar imageopen_ranger ( 2018-04-17 08:04:12 -0600 )edit

lol, i didn't see it.

berak gravatar imageberak ( 2018-04-17 08:06:13 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-04-17 00:54:38 -0600

Seen: 1,526 times

Last updated: Apr 17 '18