검색결과 리스트
글
OpenCV Image Filtering
컴퓨터비전/영상처리/OpenCV
2015. 7. 13. 01:01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | // Reference : http://docs.opencv.org/3.0.0/dc/dd3/tutorial_gausian_median_blur_bilateral_filter.html // Examples : Smoothing Images #include <iostream> #include <cv.hpp> #include <windows.h> using namespace std; using namespace cv; int DELAY_CAPTION = 1500; int DELAY_BLUR = 100; int MAX_KERNEL_LENGTH = 31; int display_caption(char *caption); int display_dst(int delay); char window_name[] = "Filter Demo 1"; Mat src, dst; int main() { namedWindow(window_name); Sleep(2000); src = imread("img/lena.bmp"); if (display_caption("Original Image") != 0) return 0; dst = src.clone(); if (display_dst(DELAY_CAPTION) != 0) return 0; for (int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2) { blur(src, dst, Size(i, i), Point(-1, -1)); if (display_dst(DELAY_BLUR) != 0) return 0; if (display_caption("Gaussian Blur") != 0) return 0; for (int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2) { GaussianBlur(src, dst, Size(i, i), 0, 0); if (display_dst(DELAY_BLUR) != 0) return 0; } if (display_caption("Median Blur") != 0) return 0; for (int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2) { medianBlur(src, dst, i); if (display_dst(DELAY_BLUR) != 0) return 0; } if (display_caption("Bilateral Blur") != 0) return 0; for (int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2) { bilateralFilter(src, dst, i, i * 2, i / 2); if (display_dst(DELAY_BLUR) != 0) return 0; } display_caption("End"); waitKey(0); return 0; } } int display_caption(char *caption) { dst = Mat::zeros(src.size(), src.type()); putText(dst, caption, Point(src.cols / 4, src.rows / 2), FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255)); imshow(window_name, dst); int c = waitKey(DELAY_CAPTION); if (c >= 0) return -1; return 0; } int display_dst(int delay) { imshow(window_name, dst); int c = waitKey(delay); if (c >= 0) return -1; return 0; } | cs |
'컴퓨터비전/영상처리 > OpenCV' 카테고리의 다른 글
OpenCV Scene Change Detection(장면 전환 검출) (0) | 2015.07.19 |
---|---|
Image Segmentation with Distance Transform and Watershed Algorithm (0) | 2015.07.13 |
OpenCV 엠보싱, 수채화, 컬러 스케치 효과 (0) | 2014.11.04 |
사람얼굴을 검출해보자 (OpenCV) (6) | 2014.10.28 |
OpenCV 요약 정리(자주쓰는 기능) (0) | 2014.10.23 |