@챈챈/#ImageProcessing

[컴퓨터비전] C/C++ Sobel Edge(소벨 에지) 검출

자바장인 2020. 1. 30. 11:14

소벨 오퍼레이터는 어윈 소벨이라는 분이 고안해낸 가장자리 검출 알고리즘입니다

3x3크기의 행렬을 사용하여 연산을 했을 때 중심을 기준으로 각 방향의 앞뒤의 값을 비교하여 변화량을 검출하는 알고리즘입니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<opencv2/opencv.hpp>
using namespace cv;
 
int main()
{
    Mat in_image, out_image;
    in_image = imread("lena_gray.jpg"0);
 
    namedWindow("in_image");
    imshow("in_image", in_image);
    int ddepth = CV_8U;
 
    Sobel(in_image, out_image, ddepth, 11);
    threshold(out_image, out_image, 25255, THRESH_BINARY);
 
    namedWindow("Sobel");
    imshow("Sobel",out_image);
 
    waitKey(0);
    return 0;
}