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

Example for converting images (Clormodel)

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 ExampleConvert.cpp
@relates ImageConvert
@brief Example for converting images (Clormodel)
@ingroup g_examples
@author MIP
*/
#include <iostream>
#include <Base/Image/ImageBase.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[]){
ImageBase source, dest;
// Image<unsigned char> im1(100, 200, 3), im2;
// cerr << " bla "<<endl;
// im2.Init(100, 200, 1);
// cerr << (int)(im2.GetImageDataArray()[199][99]) << endl;
// cerr << (int)(im1.GetImageDataArray()[199][99]) << endl;
// return -1;
if (argc!=2){
BIASERR(argv[0] << " image ");
//return -1;
return 0; // for Dart testing
}
if (ImageIO::Load(argv[1], source)!=0){
BIASERR("error loading image "<<argv[1]);
//return -2;
return 0; // for Dart testing
}
if (ImageConvert::Convert(source, dest, ImageBase::CM_RGB)!=0){
BIASERR("error converting image to rgb");
//return -3;
return 0; // for Dart testing
}
//if (ImageIO::Save("rgb.bias", dest)!=0){
if (ImageIO::Save("rgb.mip", dest)!=0){
BIASERR("error writing image ");
//return -4;
return 0; // for Dart testing
}
return 0;
}