This example shows how to insert operations into GraphManager.
#include <GraphManager.hpp>
#include <TransformImage.hpp>
#include <iostream>
using std::cout;
using std::endl;
using namespace FotoSHOCKcore;
template <typename PixelFormat>
public:
m_bands = bands;
}
void operator()(PixelFormat* in, PixelFormat* out) {
for (unsigned int i = 0; i < m_bands; ++i) {
out[i] = in[i] + 1;
}
}
private:
unsigned int m_bands;
};
public:
virtual void runOperation (
const Inputs& sources,
const Outputs& dest, vector<UpdateInfo>& ROI,
const long stamp) {
switch(sources[0]->getPixelData().format()) {
#define FORMAT_DO_STH(T,U) transformImage<T>(sources[0], dest[0], \
AddOneFunctor<U>(sources[0]->getPixelData().numOfBands()), ROI, stamp);
case_ANY;
#undef FORMAT_DO_STH
}
}
};
public:
virtual void runOperation (
const Inputs& sources,
const Outputs& dest, vector<UpdateInfo>& ,
const long ) {
switch(sources[0]->getPixelData().format()) {
#define FORMAT_DO_STH(T,U) average_impl(static_cast<ImageBuffer<T>*>((*(sources[0]))[0]), \
static_cast<ImageBuffer<T>*>((*(sources[1]))[0]), \
static_cast<ImageBuffer<T>*>((*dest[0])[0]));
case_ANY;
#undef FORMAT_DO_STH
}
}
virtual const unsigned int getNumInputs() const {
return 2;
}
private:
template <ValueType::Enum PixelFormat>
for (; srcaIt != srcaLr; ++srcaIt, ++srcbIt, ++destIt) {
destIt[band] = (srcaIt[band] + srcbIt[band]) / 2;
}
}
}
};
public:
virtual const char* name() {return "Add One";}
virtual const char* description() {return "Adds one to each pixel.";}
};
public:
virtual const char* name() {return "Average";}
virtual const char* description() {return "Computes an average of two inputs.";}
return proto;
}
};
template <typename ValueType::Enum PixelFormat>
cout << "Tile content" << endl;
for (unsigned int tileVert = 0; tileVert < tilesV; ++tileVert) {
cout << "\t";
for (unsigned int tileHoriz = 0; tileHoriz < tilesH; ++tileHoriz) {
cout << "(" << tileHoriz << ", " << tileVert << "): " << (unsigned int)it[0] << " ";
}
cout << endl;
}
}
int main() {
cout << "Content of a black root node" << endl;
switch(format.format()) {
#define FORMAT_DO_STH(T,U) printTileContent(static_cast<ImageBuffer<T>*>(rootBlack->getBuffer()));
case_ANY;
#undef FORMAT_DO_STH
}
cout << endl;
cout << "Content of a white root node" << endl;
switch(format.format()) {
#define FORMAT_DO_STH(T,U) printTileContent(static_cast<ImageBuffer<T>*>(rootWhite->getBuffer()));
case_ANY;
#undef FORMAT_DO_STH
}
cout << endl;
cout << "Content of a node adding one to the black root node content" << endl;
cout << "with a ROI in the tile (0, 0)" << endl;
switch(format.format()) {
#define FORMAT_DO_STH(T,U) printTileContent(static_cast<ImageBuffer<T>*>(op1->getBuffer()));
case_ANY;
#undef FORMAT_DO_STH
}
cout << endl;
cout << "Content of a node adding average of the previous node and white" << endl;
cout << "with a ROI specifying the entire buffer" << endl;
switch(format.format()) {
#define FORMAT_DO_STH(T,U) printTileContent(static_cast<ImageBuffer<T>*>(op2->getBuffer()));
case_ANY;
#undef FORMAT_DO_STH
}
cout << endl;
cout << "Content of the previous node after inserting two new \"add one\"" << endl;
cout << "nodes after the \"add one\" node" << endl;
switch(format.format()) {
#define FORMAT_DO_STH(T,U) printTileContent(static_cast<ImageBuffer<T>*>(op2->getBuffer()));
case_ANY;
#undef FORMAT_DO_STH
}
cout << endl;
}