개발/OpenCV

가우시안 필터(블러) Gaussian Filter(Blur)

njsung 2018. 4. 9. 23:10
반응형
#include <opencv\highgui.h>
#include <opencv2\opencv.hpp>

using namespace cv;

int main() {
	
	cvNamedWindow("Origin", CV_WINDOW_AUTOSIZE);
	cvNamedWindow("Filter3", CV_WINDOW_AUTOSIZE);
	cvNamedWindow("Filter5", CV_WINDOW_AUTOSIZE);
	cvNamedWindow("Filter7", CV_WINDOW_AUTOSIZE);
	cvNamedWindow("Filter9", CV_WINDOW_AUTOSIZE);

	Mat inputImg;
	Mat filter3Img;
	Mat filter5Img;
	Mat filter7Img;
	Mat filter9Img;

	inputImg = imread("cat.png", CV_LOAD_IMAGE_COLOR);
	resize(inputImg, inputImg, Size(), 0.3, 0.3, CV_INTER_AREA);

	// Gaussian Filer 적용
	GaussianBlur(inputImg, filter3Img, Size(3, 3), 0);
	GaussianBlur(inputImg, filter5Img, Size(5, 5), 0);
	GaussianBlur(inputImg, filter7Img, Size(7, 7), 0);
	GaussianBlur(inputImg, filter9Img, Size(9, 9), 0);

	imshow("Origin", inputImg);
	imshow("Filter3", filter3Img);
	imshow("Filter5", filter5Img);
	imshow("Filter7", filter7Img);
	imshow("Filter9", filter9Img);

	waitKey(0);


	return 0;
}

가우시안 필터(가우시안 블러)를 이미지에 적용하는 코드입니다.


가우시안 필터를 적용한 결과입니다.




반응형