1 | initial version |
thanks to @sturkmen input I did some edge detection with Sobel. This is a working snippet of my code:
Mat rgbPanSharpen = Imgcodecs.imread(rgbPanSharpenImage, Imgcodecs.IMREAD_UNCHANGED);
Mat gaussian = new Mat();
Imgproc.GaussianBlur(rgbPanSharpen, gaussian, new Size(5, 5), 0);
Mat grad_x = new Mat();
Mat grad_y = new Mat();
Mat abs_grad_x = new Mat();
Mat abs_grad_y = new Mat();
Imgproc.Sobel(gaussian, grad_x, CvType.CV_16S, 1, 0, 3, 1, 0, Core.BORDER_DEFAULT);
Core.convertScaleAbs(grad_x, abs_grad_x);
Imgproc.Sobel(gaussian, grad_y, CvType.CV_16S, 0, 1, 3, 1, 0, Core.BORDER_DEFAULT);
Core.convertScaleAbs(grad_y, abs_grad_y);
// Total Gradient (approximate)
Mat grad = new Mat();
Core.addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
Imgcodecs.imwrite(path + SEPARATOR + "sobel.png", grad);