개발/OpenCV
Canny Edge Detection
njsung
2018. 4. 10. 21:28
반응형
#include <opencv\highgui.h>
#include <opencv2\opencv.hpp>
#include <opencv cv.h>
using namespace cv;
int main() {
IplImage *inputImg = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_GRAYSCALE);
IplImage *edgeDetection1 = cvCreateImage(cvGetSize(inputImg), IPL_DEPTH_8U, 1);
IplImage *edgeDetection2 = cvCreateImage(cvGetSize(inputImg), IPL_DEPTH_8U, 1);
IplImage *edgeDetection3 = cvCreateImage(cvGetSize(inputImg), IPL_DEPTH_8U, 1);
cvNamedWindow("InputImage", CV_WINDOW_AUTOSIZE);
cvShowImage("InputImage", inputImg);
cvCanny(inputImg, edgeDetection1, 50, 100, 3);
cvCanny(inputImg, edgeDetection2, 50, 200, 3);
cvCanny(inputImg, edgeDetection3, 10, 100, 3);
cvShowImage("Edge1", edgeDetection1);
cvShowImage("Edge2", edgeDetection2);
cvShowImage("Edge3", edgeDetection3);
cvWaitKey(0);
return 0;
}
캐니 엣지를 활용한 윤곽선 검출 예제 입니다.
결과화면은 다음과 같습니다.
반응형