#include <vigra/multi_array.hxx>
#include <vigra/multi_math.hxx>
#include <iostream>
int main (int argc, char ** argv)
{
if(argc != 4)
{
std::cout << "Usage: " << argv[0] << " infile1 infile2 outfile" << std::endl;
return 1;
}
try
{
ImageImportInfo info1(argv[1]),
info2(argv[2]);
MultiArray<2, RGBValue<UInt8> > imageArray1(info1.shape()),
imageArray2(info2.shape());
Shape2 resultShape = min(info1.shape(), info2.shape());
MultiArray<2, RGBValue<UInt8> > exportArray(resultShape);
Shape2 start1 = (info1.shape() - resultShape) / 2,
end1 = start1 + resultShape;
MultiArray<2, RGBValue<UInt8> > subImageArray1 = imageArray1.subarray(start1, end1);
Shape2 start2 = (info2.shape() - resultShape) / 2,
end2 = start2 + resultShape;
MultiArray<2, RGBValue<UInt8> > subImageArray2 = imageArray2.subarray(start2, end2);
using namespace multi_math;
exportArray = 0.5*subImageArray1 + 0.5*subImageArray2;
}
catch (std::exception & e)
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}
void importImage(...)
Read an image from a file.
void exportImage(...)
Write an image to a file.
image import and export functions
std::string impexListFormats()
List the image formats VIGRA can read and write.