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

Example for the structure tensor

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 ExampleStructureTensor.cpp
@brief Example for the structure tensor
@relates StructureTensor
@ingroup g_examples
@author MIP
*/
#include <Filter/StructureTensor.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
using namespace BIAS;
using namespace std;
#define type 0
#if type == 0
#ifdef BUILD_IMAGE_INT
#define StorageType unsigned char
#define OutputImageType int
#else
#define StorageType unsigned char
#define OutputImageType float
#endif
#elif type == 1
#define StorageType float
#define OutputImageType float
#endif
int main(int argc, char *argv[])
{
Image<OutputImageType> im, sgxx, sgxy, sgyy;
int argind = 1;
if (argc-argind<1 || argind<1){
cerr << argv[0] << " [parameter] <im1> <im2> [ <im3> ... ] \n";
return -2;
}
// set debuglevel
//st.AddDebugLevel(D_ST_WRITE_DEBUG_IM);
for (int i=argind; i<argc; i++){
if (ImageIO::Load(argv[i], ucim)!=0){
BIASERR("error loading image "<<argv[i]);
return -1;
} else {
cerr << "read "<<argv[i]<<endl;
}
if (ImageConvert::ConvertST(ucim, im, im.GetStorageType())!=0){
BIASERR("error converting image "<<argv[i]);
}
st.CalcStructureTensor(im, sgxx, sgxy, sgyy);
ostringstream name;
name << "sgxx-"<<setw(4)<<setfill('0')<<i-argind<<".ppm";
ImageIO::Save(name.str(), sgxx, ImageIO::FF_ppm);
name.str("");
name << "sgxy-"<<setw(4)<<setfill('0')<<i-argind<<".ppm";
ImageIO::Save(name.str(), sgxy, ImageIO::FF_ppm);
name.str("");
name << "sgyy-"<<setw(4)<<setfill('0')<<i-argind<<".ppm";
ImageIO::Save(name.str(), sgyy, ImageIO::FF_ppm);
}
return 0;
}