Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleTile.cpp

Example for pasting an image to an Image ROI (Region Of Interest)

, ImageBase

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@example ExampleTile.cpp
@relates ROI, ImageBase
@brief Example for pasting an image to an Image ROI (Region Of Interest)
@ingroup g_examples
@author MIP
*/
#include <iostream>
#include <Base/Image/ImageBase.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
unsigned int tilecount=2;
unsigned int x, y;
if (argc!=2){
BIASERR(argv[0] << " image ");
//return -1;
return 0; // for Dart testing
}
if (ImageIO::Load(argv[1], src)!=0){
BIASERR("error loading image "<<argv[1]);
//return -2;
return 0; // for Dart testing
}
dst.Init(src.GetWidth()*tilecount, src.GetHeight()*tilecount,
for (y=0; y<dst.GetHeight(); y+=src.GetHeight()){
for (x=0; x<dst.GetWidth(); x+=src.GetWidth()){
dst.SetROI(x, y, x+src.GetWidth(), y+src.GetHeight());
if (dst.Paste2ROI(src)!=0){
BIASERR("error pasting to ROI");
}
}
}
//if (ImageIO::Save("tile", dst)!=0){
if (ImageIO::Save("tile", dst)!=0){
BIASERR("error writing image ");
return -4;
}
if (ImageIO::Save("tile", dst, ImageIO::FF_ppm)!=0){
BIASERR("error exporting image ");
return -2;
}
return 0;
}