코드
#include "opencv2/opencv.hpp"
#include <opencv/cv.h>
#include <iostream>
using namespace cv;
using namespace std;
int main() {
Mat image = imread("image/food.jpg", CV_LOAD_IMAGE_COLOR);
namedWindow("video", CV_WINDOW_AUTOSIZE);
namedWindow("Canny", CV_WINDOW_AUTOSIZE);
namedWindow("Sobel", CV_WINDOW_AUTOSIZE);
// Original Image to Gray Image
Mat gray;
cvtColor(image, gray, CV_BGR2GRAY);
// Sobel Filter
Mat sobelX;
Mat sobelY;
Sobel(gray, sobelX, CV_8U, 1, 0);
Sobel(gray, sobelY, CV_8U, 0, 1);
Mat imageSobel;
imageSobel = abs(sobelX) + abs(sobelY);
Mat imageCanny;
Canny(gray, imageCanny, 50, 200);
imshow("video", image);
imshow("Canny", imageCanny);
imshow("Sobel", imageSobel);
waitKey(0);
}
결과값
'Programming > openCV' 카테고리의 다른 글
11. Emboss, sketch, 수채화 (0) | 2017.04.04 |
---|---|
10. 마우스로 영역을 지정한 부분만 엣지 검출 (0) | 2017.04.04 |
8. 영상을 Canny Edge Detection 후 저장하기 / 영상 정보 출력하기 (0) | 2017.04.04 |
7. 비디오 출력하기 (0) | 2017.04.04 |
6. 디졸브와 트랙바 (0) | 2017.04.04 |