opencv学习笔记8 高斯金字塔,拉普拉斯金字塔,调整大小
一。图像金字塔
高斯金字塔用来向下降采样图像
拉普拉斯金字塔用来从金字塔底层图像中向上采样重建一个图像
1.像上采样
void pyrUp(InputArray src, OutputArraydst, const Size& dstsize=Size(), int borderType=BORDER_DEFAULT )
2.向下采样
void pyrDown(InputArray src,OutputArray dst, const Size& dstsize=Size(), int borderType=BORDER_DEFAULT)
1 #include<opencv.hpp> 2 using namespace cv; 3 int main() 4 { 5 Mat src = imread("F:/opencv/lena.jpg"); 6 Mat pyrup,pyrdown; 7 pyrUp(src, pyrup, Size(src.cols * 2, src.rows * 2)); //图片放大 8 pyrDown(src, pyrdown, Size(src.cols / 2, src.rows / 2)); //图片缩小 9 imshow("src", src); 10 imshow("pyrup", pyrup); 11 imshow("pyrdown", pyrdown); 12 waitKey(); 13 return 0; 14 }
二。调整图像大小
void resize(InputArray src,OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR )
1 #include<iostream> 2 #include<vector> 3 #include<opencv2/opencv.hpp> 4 using namespace std; 5 using namespace cv; 6 int main() 7 { 8 Mat src = imread("E:/test.jpg"); 9 Mat dst1, dst2 = Mat::zeros(1000, 1000,CV_8UC3); 10 imshow("src", src); 11 resize(src, dst1, Size(), 0.5, 0.5); 12 imshow("dst1", dst1); 13 resize(src, dst2, dst2.size()); 14 imshow("dst2", dst2); 15 waitKey(); 16 return 0; 17 }