Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV - Java : inRange function

I have my image mRgba and when I do this :

Core.inRange(mRgba, B1, B2, mRgba);

I have the result that I expect : all my RGBA image is thresholded between B1 and B2.

Now I want to do this :

Mat roi = mRgba.submat(rect);
Core.inRange(roi, B1, B2, roi);

And it's not apply on my area rectangle, I try everything since 3 hours I can't find a solution...

like image 932
Bidonjour Avatar asked Feb 17 '15 20:02

Bidonjour


1 Answers

OK, maybe everybody doesn't care, but after many tries, i found the answer.

Mat roi = new Mat();
roi = mRgba.submat(rect);
Mat roiTmp = roi.clone();

Imgproc.cvtColor(roiTmp, roiTmp, Imgproc.COLOR_RGB2HSV);

Core.inRange(roiTmp, B1, B2, roiTmp);

Imgproc.cvtColor(roiTmp, roi, Imgproc.COLOR_GRAY2BGRA);
like image 141
Bidonjour Avatar answered Sep 29 '22 06:09

Bidonjour