First time here? Check out the FAQ!
answered 2016-04-20 03:54:37 -0600
your mask is not initialized properly. it has the right size / type, but the pixels contain uninitialized data.
Mat mask = Mat.zeros(submatrix.rows(), submatrix.cols(), CvType.CV_8UC1);
should do , what you want.