Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The hint in the comments led into the right direction. With a bit of additional decoration the problem could be solved with Core.compare() . Give are matrices a and b and their numerical ids id_a and id_b (id_b>id_a):

Mat id_a_mat = new Mat(a.size(),CvType.CV8UC1);
Core.add(id_a_mat,new Scalar(id_a),id_a_mat);
Mat bigger = new Mat();
Core.compare(a,b,bigger,Core.CMP_LT);  // <----
Mat bigger_id_b = new Mat();
Imgproc.threshold(bigger,bigger_id_b,128,id_b,CvType.CV8UC1);
Mat d = new Mat();
Core.max(id_a_mat,bigger_id_b,d);
Mat c = new Mat();
Core.max(a,b,c);

[NB: The tone around here seems quite rough...]