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