forked from deepakkrish212/images-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
66 lines (54 loc) · 2.41 KB
/
Copy pathmain.cpp
File metadata and controls
66 lines (54 loc) · 2.41 KB
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
/*
* Deepak Krishnaa Govindarajan
* Marcus Naess
* Soobin Rho
* Fall, 2022
* COSC 226: C++ Programming
*
* Hw: A Container class for handling images.
*/
#include "Image.h"
using namespace std;
int main() {
// ----------------------------------------------------------------
// 1. Create a constant image and print a histogram of the image
// ----------------------------------------------------------------
const int CONSTANT_COLOR {13};
Image imageGrey {CONSTANT_COLOR};
pgmPrintHistogram(imageGrey);
// Print a whitespace for better readability
cout<<'\n';
// ----------------------------------------------------------------
// 2. Create a gradient image and print a histogram of the image
// ----------------------------------------------------------------
Image imageGradient {}; // Default constructor creates a gradient
pgmPrintHistogram(imageGradient);
// ----------------------------------------------------------------
// 3. Save the example image files
// ----------------------------------------------------------------
pgmSaveAsFile(imageGrey,"imageGrey.pgm");
pgmSaveAsFile(imageGradient,"imageGradient.pgm");
// ----------------------------------------------------------------
// 4. Construct using an existing pgm file
// ----------------------------------------------------------------
Image imageFromFile {"imageGradient.pgm"};
// ----------------------------------------------------------------
// 5. Adjust brightness and then save as two files:
// "imageAdjusted.pgm" is saved in P2 form (ASCII).
// "imageAdjustedBinary.pgm" is saved in P5 form (binary).
// ----------------------------------------------------------------
imageFromFile.setBrightness(1,-5);
pgmSaveAsFile(imageFromFile,"imageAdjusted.pgm");
pgmSaveAsFile(imageFromFile,"imageAdjustedBinary.pgm","P5");
Image subset {"gator.pgm"};
Image subsetreturn = subset.subset(100,100,200,200);
pgmSaveAsFile(subsetreturn,"subset.pgm");
Image downsample {"gator.pgm"};
Image downsampleReturn = downsample.downsample(false);
pgmSaveAsFile(downsampleReturn,"downsample.pgm");
Image downsampleSmooth {"gator.pgm"};
Image downsampleSmoothReturn = downsampleSmooth.downsample(true);
pgmSaveAsFile(downsampleSmoothReturn,"downsampleSooth.pgm");
// Return 0 to signal success
return 0;
}