影象的縮放和高斯不同
阿新 • • 發佈:2019-01-27
// 影象金字塔上取樣降取樣.cpp: 定義控制檯應用程式的入口點。
//
#include "stdafx.h"
#include "opencv2/opencv.hpp"]
#include "iostream"
using namespace cv;
using namespace std;
int main()
{
Mat src,downImage, upImage;
src = imread("angelababy.jpg");
imshow("src", src);
//每次只能放大或縮小一倍,不能跳著放大
pyrDown(src, downImage, Size(src.cols >> 1 , src.rows >> 1)); //降取樣 縮小
pyrUp(src, upImage, Size(src.cols << 1, src.rows << 1)); //上取樣 放大
imshow("pryDown", downImage);
imshow("pryUp", upImage);
//Difference of Gaussian(DOG) 高斯不同
Mat gray_image, g1, g2 , dogImage;
cvtColor(src, gray_image, CV_BGR2GRAY);
GaussianBlur(gray_image, g1, Size(3 ,3),0);
GaussianBlur(g1, g2, Size(3, 3), 0);
subtract(g1, g2, dogImage);
normalize(dogImage, dogImage, 255, 0, NORM_MINMAX);
bitwise_not(dogImage, dogImage);
imshow("DOG", dogImage);
waitKey();
return 0;
}