This very simple demos shows how to use libidx and libidxgui. We first load an image with load_image(), display it, then select the blue channel and multiply it by 0.5 and display the image again.
#include "eblearn/libidx.h"
#include "eblearn/libidxgui.h"
using namespace std;
using namespace ebl;
MAIN_QTHREAD(int, argc, char **, argv) { // macro to enable multithreaded gui
try {
// paths
string ebl = "/home/pierre/eblearn/"; // set your eblearn root
string image = ebl;
image << "tools/data/barn.png";
// load and display image
idx<float> m = load_image<float>(image);
draw_matrix(m);
gui << "original image";
// reduce blue in image
idx<float> blue = m.select(2, 2); // select blue channel
idx_dotc(blue, .5, blue); // multiply blue channel by .5
draw_matrix(m, (uint) 0, m.dim(1) + 5);
gui << at(0, m.dim(1) + 5) << "50% blue";
} eblcatch();
return 0;
}
# This makefile assumes eblearn headers are installed on the system
# (using make install)
includes = -I/usr/include/qt4 \
-I/usr/include/qt4/Qt \
-I/usr/include/qt4/QtGui \
-I/usr/include/qt4/QtCore
links = -lidx -lidxgui
options = -D__IMAGEMAGICK__ # let eblearn know that image magick is present
all:
g++ simple.cpp ${links} ${includes} ${options}