샤르 가장자리 감지 연산자를 사용하면 가로 및 세로 방향 모두에서 주어진 이미지의 가장자리를 찾을 수 있습니다.
Scharr() Imgproc 클래스의 메소드는 Scharr 을 적용합니다. 주어진 이미지에 대한 에지 감지 알고리즘. 이 방법은 -
-
소스 및 대상 이미지를 나타내는 두 개의 매트 개체입니다.
-
이미지의 깊이를 나타내는 정수 변수입니다.
-
x 및 y 도함수를 유지하는 두 개의 이중 변수
예시
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class ScharrEdgeDetection {
public static void main(String args[]) {
//Loading the OpenCV core library
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
String file ="D:\\Images\\win2.jpg";
Mat src = Imgcodecs.imread(file);
//Creating an empty matrix for the destination image
Mat dst = new Mat();
//Applying Scharr derivative with values x:1 y:0
Imgproc.Scharr(src, dst, Imgproc.CV_SCHARR, 0, 1);
HighGui.imshow("Scharr - x:0 & y:1 ", dst);
//Applying Scharr derivative with values x:1 y:0
Imgproc.Scharr(src, dst, Imgproc.CV_SCHARR, 1, 0);
HighGui.imshow("Scharr - x:1 & y:0 ", dst);
HighGui.waitKey();
}
} 입력 이미지

출력
실행 시 위의 프로그램은 다음 창을 생성합니다. -
샤르 - x:0 및 y:1 - 
샤르 - x:1 및 y:0 - 