#include #include "bmpimage.h" 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() { lab01(); return 0; }