so, problem is, you have an argb
image on the java side and an expected bgr
Mat on the c++ side.
maybe you can use mixChannels():
Mat argb2bgr(const Mat &m) {
Mat _r(m.rows, m.cols, CV_8UC3);
mixChannels({m}, {_r}, {1,2, 2,1, 3,0}); // drop a, swap r,b
return _r;
}
you also dont need to split anything into channels:
Mat dehaze(const Mat &argb, Scalar tw=Scalar(0.8, 0.8, 0.5)) {
// convert to rgb, [0...1]
Mat image = argb2bgr(argb);
image.convertTo(image, CV_64F, 1.0/255);
GaussianBlur(image, blurred, Size(41, 41), 30, 30);
// each channel on its own row
Mat channels = blurred.reshape(1,blurred.total());
// check for max along x axis
Mat maxVals;
reduce(channels, maxVals, 0, REDUCE_MAX, image.depth());
Mat tbgr = (Scalar::all(1.0) - blurred.mul(tw)) / maxVals;
}
btw, do you have a link to the algorithm you try to implement here ?