Ask Your Question

How manage RGB Pan sharpened image

asked 2017-12-03 05:33:29 -0500

procton gravatar image

updated 2017-12-03 06:10:18 -0500

I have a high resolution (about 30 cm) RGB pan sharpened image (3 channels, 16x3 bit). My need is to make some edge detection aimed to segment human artifacts.

I load the image with Mat rgbPanSharpen = Imgcodecs.imread(rgbPanSharpenImage, Imgcodecs.IMREAD_UNCHANGED); but after that I have some doubts on how proceed.

I think I could work on single channels (using Core.split) having single 16 bit images, may be also converting to 8 bit, but I am afraid this approach is lossy.

Which should be the correct approach to make edge detection on such kind of images ? (I don't ask for code, just the correct logical approch to follow)

This a sample image

edit retag flag offensive close merge delete


could you upload the image somewhere

sturkmen gravatar imagesturkmen ( 2017-12-03 05:37:24 -0500 )edit

I edited my answer to add a sample image

procton gravatar imageprocton ( 2017-12-03 06:10:04 -0500 )edit

did you try to apply Sobel. take a look at the tutorial code (i can send the compiled executable if you need)

sturkmen gravatar imagesturkmen ( 2017-12-03 09:08:25 -0500 )edit

thank you @sturkmen. I tried Sobel and I am able to make edge detection (I can share code if you believe it can be useful). So your overall suggestion is to work with the full image, without splitting.

procton gravatar imageprocton ( 2017-12-03 10:20:43 -0500 )edit

in this forum working code snippets are always welcome i think.

sturkmen gravatar imagesturkmen ( 2017-12-03 10:26:26 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-05 13:12:23 -0500

procton gravatar image

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);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-12-03 05:33:29 -0500

Seen: 389 times

Last updated: Dec 05 '17