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

demonstrates reading of RAW4096 image format Reads a .raw RAW4096 image which contains a scorpion 1600x1200 Bayer raw pattern with 8 bpp and writes it as a jpeg. This format is used by Mediendom project by Jan Woetzel and Juergen Rienow 2005.

Author
Jan Woetzel 05/2005
/*
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
*/
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Debug/Error.hh>
#include <Base/Debug/DebugSimple.hh>
// ----------------------
using namespace std;
using namespace BIAS;
/**
@example ExampleConvertRAW.cpp
@relates ImageConvert
@brief demonstrates reading of RAW4096 image format Reads a .raw RAW4096
image which contains a scorpion 1600x1200 Bayer raw pattern with 8 bpp
and writes it as a jpeg. This format is used by Mediendom project by
Jan Woetzel and Juergen Rienow 2005.
@author Jan Woetzel 05/2005
*/
void usage(int /*argc*/, char** /*argv*/)
{
cout<<"usage: readRAW <img.raw> <out.jpg> <jpgQuality>"<<endl
<<"author: Jan Woetzel"<<endl;
}
// main entry for console application
int main(int argc, char** argv){
if (argc==1) usage(argc, argv);
cout<<"started ";
if (argc>0) cout<<argv[0];
cout<<endl;
string in("img.raw");
string out("img_out.jpg");
unsigned int quality=100;
if (argc>1) in =argv[1];
if (argc>2) out=argv[2];
if (argc>3) quality=atoi(argv[3]);
// work:
int result = 0;
if (result!=0) {
cout<<"could not load image "<<in<<endl;
return -2;
};
/// to RGB convert 1 ch Bayer --> 3 channel RGB
// write result:
result = ImageIO::Save(out, imgRGB, BIAS::ImageIO::FF_jpg, false, quality,false,false);
if (result!=0)
cout<<"could not write image."<<endl;
#ifdef BIAS_HAVE_OPENCV
imgRGB.Display("imgRGB",true, false, true, 6000);
#endif // BIAS_HAVE_OPENCV
cout<<"done."<<endl;
}