-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path高图-Lab8图像金字塔.cpp
74 lines (56 loc) · 1.34 KB
/
高图-Lab8图像金字塔.cpp
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
//图像灰度变换
#include<iostream>
#include<string>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/core/core_c.h>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
void test1()
{
//缩放
Mat image;
image = imread("lena.jpg", IMREAD_COLOR); // Read the file
imshow("原图", image); // Show our image inside it.
Mat dst = Mat::zeros(256, 256, CV_8UC3); //我要转化为512*512大小的
resize(image, dst, dst.size());
imshow("尺寸调整之后", dst);
waitKey(0); // Wait for a keystroke in the window
destroyAllWindows();
return ;
}
void test2(double a, double b)
{
Mat image = imread("lena.jpg");
imshow("原图", image);
Mat dst;
resize(image, dst, Size(), a, b);//我长宽都变为原来的0.5倍
imshow("尺寸调整之后", dst);
waitKey(0);
destroyAllWindows();
return;
}
void test3()
{
Mat image = imread("lena.jpg");
imshow("原图", image);
Mat dst, dst2;
pyrUp(image, dst, Size(image.cols * 2, image.rows * 2)); //放大一倍
pyrDown(image, dst2, Size(image.cols * 0.5, image.rows * 0.5)); //缩小为原来的一半
imshow("尺寸放大之后", dst);
imshow("尺寸缩小之后", dst2);
waitKey(0);
destroyAllWindows();
return;
}
int main()
{
test1();
test2(0.3, 0.3);
test3();
return 0;
}