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
|
#include <iostream>
#include <iomanip>
using namespace std;
const int height = 5; // image height variable || Change to 6 or any other value it crashes???
// Procedure that takes the original grayscale image and turns it into a negated image, then displays it to the console.
void negatedImage(double imageI[height][5], int height) {
double imageJ[5][height] = {imageI[height][5]};
cout << "Negated Image: " << endl;
for(int i=0; i < height; i++) { // This loops through the rows.
for(int j=0; j < height; j++) { // This loops through the columns
imageJ[i][j] = 1 - imageI[i][j];
cout << setprecision(2) << fixed;
cout << imageJ[i][j] << " ";
}
}
}
// Procedure that takes the grayscale image and displays it to the console.
void displayImageData(double imageI[height][5], int height) {
cout << "Grayscale Image: " << endl;
for(int i=0; i < height; i++) { // This loops through the rows.
for(int j=0; j < height; j++) { // This loops through the columns
cout << setprecision(2) << fixed;
cout << imageI[i][j] << " ";
}
}
cout << endl;
negatedImage(imageI, height); // call procedure to negate the image
}
int main() {
// image pixels
double imageI[height][5] = {{ 0.00 , 0.25 , 0.50 , 0.25, 0.00 }
,{ 0.20 , 0.40 , 0.60 , 0.80, 1.00 }
,{ 0.25 , 0.50, 1.00, 0.50, 0.25 }
,{ 0.20, 0.40, 0.60, 0.80, 1.00 }
,{ 0.20, 0.40, 0.60, 0.80, 1.00 }};
displayImageData(imageI, height); // call procedure to display original image pixel numbers
return 0;
}
|