lab01_Ver0.1

This commit is contained in:
Евгений Титаренко 2024-04-03 08:56:21 +03:00
parent 570986b499
commit 9762c44796

View file

@ -4,9 +4,32 @@
const std::string FILENAME = "../elef.bmp";
const std::string FILENAME_OUT = "../elef_out.bmp";
void lab01() {
auto og_image = readBMPImage(FILENAME);
auto pixels = og_image.pixels_copy();
for (int i = 0; i < og_image.height(); ++i) {
for (int j = 0; j < og_image.width(); ++j) {
uint8_t gray = pixels[i][j].r / 3 + pixels[i][j].g / 3 + pixels[i][j].b / 3;
pixels[i][j] = {gray, gray, gray};
}
}
auto image1 = new BMPImage(og_image.fileHeader_copy(), og_image.infoHeader_copy(), pixels);
auto pixels2 = image1->pixels_copy();
for (int i = 0; i < og_image.height(); ++i) {
for (int j = 0; j < og_image.width(); ++j) {
uint8_t gray = 0;
if (pixels2[i][j].r > 80) gray = 255;
pixels2[i][j] = {gray, gray, gray};
}
}
auto image2 = new BMPImage(og_image.fileHeader_copy(), og_image.infoHeader_copy(), pixels2);
image1->write("../elef_gs.bmp");
image2->write("../elef_bw.bmp");
og_image.write("../elef_out.bmp");
// image.write(FILENAME_OUT);
}
int main() {
auto image = readBMPImage(FILENAME);
image.write(FILENAME_OUT);
lab01();
return 0;
}