图像的上采样和下采样
#include <opencv2/opencv.hpp> #include <iostream> #include <math.h> using namespace cv; using namespace std; Mat src, dst,dst2; //膨胀腐蚀的应用:消除噪声 int main() { //原图 src = imread(".//pic//kate.png", IMREAD_UNCHANGED); char* INPUT_WIN = "input image"; namedWindow(INPUT_WIN, CV_WINDOW_AUTOSIZE); imshow(INPUT_WIN, src); //上采样 pyrUp(src, dst, Size(src.cols * 2, src.rows * 2)); imshow("sample up", dst); //下采样 Mat s_down; pyrDown(src, s_down, Size(src.cols / 2, src.rows / 2)); imshow("sample down", s_down); Mat g1, g2,gray_src; cvtColor(src, gray_src, CV_BGR2GRAY); GaussianBlur(gray_src, g1, Size(3, 3), 0, 0); imshow("g1", g1); GaussianBlur(g1, g2, Size(3, 3), 0); imshow("g2", g2); subtract(g1, g2, dst2, Mat()); //归一化显示 normalize(dst2, dst2, 255, 0, NORM_MINMAX); imshow("res", dst2); waitKey(0); return 0; }
版权声明:本文为xiaochi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。