반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sobel_edge 본문

[AI]/openCV

sobel_edge

givemebro 2020. 6. 23. 10:34
반응형
#include "opencv2/opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;

void sobel_edge() {
	Mat src = imread("family.jpg",IMREAD_GRAYSCALE);

	if (src.empty()) {
		cerr << "Image load failed!" << endl;
		return ;
	}

	Mat dx, dy;
	Sobel(src, dx, CV_32FC1, 1, 0);
	Sobel(src, dy, CV_32FC1, 0, 1);

	Mat fmag, mag;
	magnitude(dx, dy, fmag);
	fmag.convertTo(mag, CV_8UC1);

	Mat edge = mag > 150;

	imshow("src", src);
	imshow("mag", mag);
	imshow("edge", edge);

	waitKey();
	destroyAllWindows();
}

int main() {
	sobel_edge();
	return 0;
}

반응형

'[AI] > openCV' 카테고리의 다른 글

QRcode read in C++  (0) 2020.06.23
adaptiveThreshold  (0) 2020.06.23
binarization  (0) 2020.06.23
Canny_edge  (0) 2020.06.23
setMouseCallback  (0) 2020.06.23
affine_transform in C++  (0) 2020.06.22
medianBlur in C++  (0) 2020.06.22
Gaussian(양방향 필터) in C++  (0) 2020.06.22
Comments