1 | initial version |
some misassumptions here:
Core.randu(blocks,0,1);
will be all 0 !>
or '<' operators, you'll have to use: Mat mask=new Mat(); Core.compare(blocks, newScalar(0.3 * 255.0), mask, Core.CMP_LT);
setTo()
calls don't make any sense, as long as you are re-using the same blocks Mat for exclusive operations.in the end, i think, you wanted this:
Mat gray = new Mat();
Utils.bitmapToMat(grayBitmap,gray);
Mat blocks = new Mat(gray.size(),gray.type());
// right border is exclusive !
Core.randu(blocks,0,256);
// lower part to 0, upper to 255
Imgproc.threshold(blocks, blocks, 255 * 0.3, 255, Imgproc.THRESH_BINARY);
2 | No.2 Revision |
some misassumptions here:
Core.randu(blocks,0,1);
will be all 0 !>
or <
operators, you'll have to use: Mat mask=new Mat(); Core.compare(blocks, newScalar(0.3 * 255.0), mask, Core.CMP_LT);
setTo()
calls don't make any sense, as long as you are re-using the same blocks Mat for exclusive operations.in the end, i think, you wanted this:
Mat gray = new Mat();
Utils.bitmapToMat(grayBitmap,gray);
Mat blocks = new Mat(gray.size(),gray.type());
// right border is exclusive !
Core.randu(blocks,0,256);
// lower part to 0, upper to 255
Imgproc.threshold(blocks, blocks, 255 * 0.3, 255, Imgproc.THRESH_BINARY);
3 | No.3 Revision |
some misassumptions here:
Core.randu(blocks,0,1);
will be all 0 !>
or <
operators, you'll have to use: Mat mask=new Mat(); Core.compare(blocks, newScalar(0.3 * 255.0), mask, Core.CMP_LT);
setTo()
calls don't make any sense, as long as you are re-using the same blocks Mat for exclusive (contradicting) operations.in the end, i think, you wanted this:
Mat gray = new Mat();
Utils.bitmapToMat(grayBitmap,gray);
Mat blocks = new Mat(gray.size(),gray.type());
// right border is exclusive !
Core.randu(blocks,0,256);
// lower part to 0, upper to 255
Imgproc.threshold(blocks, blocks, 255 * 0.3, 255, Imgproc.THRESH_BINARY);