I am Charmie

メモとログ

CImg: display image(s)

This code loads an image lena.bmp and shows the original image and its grayscaled one in a window, which shows text "Original image | Grayscale image" on its bar. [code lang="c"] std::string strFile = "lena.bmp";

cimg_library::CImg<unsigned char> img1(strFile.c_str()); cimg_library::CImg<unsigned char> img2; int color = _imgInput.spectrum(); // to check the number of color channels switch(color) { case 1: img2 = img1; break; case 3: // get 0-th color slice (Y color component) of YCbCr image format img2 = img1.get_RGBtoYCbCr().get_channel(0); break; } std::string strWindow = "Original image | Grayscale image"; (img1,img2).display(strWindow); [/code]