Skip to content

Instantly share code, notes, and snippets.

@ozooxo
Created October 9, 2014 04:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozooxo/299ab37080bba24b8c0e to your computer and use it in GitHub Desktop.
Save ozooxo/299ab37080bba24b8c0e to your computer and use it in GitHub Desktop.
Setup CImg in ubuntu 14.04
$ sudo apt-get install libx11-dev
$ sudo apt-get install cimg-dev cimg-doc cimg-examples
$ cat >lena.cpp <<EOL
#include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char> image("lena.jpg"), visu(500,400,1,3,0);
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.blur(2.5);
CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");
while (!main_disp.is_closed() && !draw_disp.is_closed()) {
main_disp.wait();
if (main_disp.button() && main_disp.mouse_y()>=0) {
const int y = main_disp.mouse_y();
visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.width()-1,y,0,0),red,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,1,image.width()-1,y,0,1),green,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,2,image.width()-1,y,0,2),blue,1,1,0,255,0).display(draw_disp);
}
}
return 0;
}
EOL
$ g++ -Wall -o lena lena.cpp -lpthread -lX11
$ ./lena
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment