Re: Problems with equalizeHist function

Skip to first unread message

Andrey Pavlenko

Jan 17, 2013, 8:13:55 AM1/17/13
what OpenCV version do you use?
I've checked the latest and the code works OK with minimal modifications:

 Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.wshed_exp);
Mat rgbMat = new Mat();
Utils.bitmapToMat(bmp, rgbMat);
Mat grayMat = new Mat();
Mat bwMat = new Mat();
Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY);
Imgproc.equalizeHist(grayMat, grayMat);
Imgproc.threshold(grayMat, bwMat, 127.5, 255.0, Imgproc.THRESH_OTSU);
Utils.matToBitmap(bwMat, bmp);

Just in case: some OpenCV version contained a bug in equalizeHist() that caused its crash in case of picture width isn't multiple of 4.
Reply all
Reply to author
0 new messages