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

Example for usage of ContourDetectorBSpline Usage: ContourDetectorBSpline example.ppm press f for fitting" <im1> [ <im2> <im3> ... ]

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 ExampleContourDetectorBSpline.cpp
@relates ContourDetectorBSpline
@brief Example for usage of ContourDetectorBSpline
Usage: ContourDetectorBSpline example.ppm
press f for fitting" <im1> [ <im2> <im3> ... ]
@ingroup g_examples
@author MIP
*/
#include "../ContourDetectorBSpline.hh"
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageBase.hh>
#include <Base/Image/Image.hh>
#include <string>
//images
//B-Spline curve
//color
unsigned char blue_[3]={0,0,255};
unsigned char red_[3]={255,0,0};
void fit(){
bspline_.SetFitSampleWidth(0.01);
//fit with alpha=0.001 normalWidth=50
bspline_.Fit(imgGrey_,0.001,50);
}
void loadInputImage(char *imgloc){
BIAS::ImageIO::Load(imgloc,imgOrig_);
BIAS::ImageIO::Load(imgloc,imgDraw_);
}
//TODO: Fix ContourBSpline and Example
int main(int argc, char *argv[])
{
std::cout<<"WARNING: Not working example!!! "<<std::endl;
if(argc==1){
std::cout<< "usage: " << argv[0] << " example.ppm" << std::endl <<
" press f for fitting" << std::endl << std::flush;
exit(EXIT_FAILURE);
}
//load example.mip
loadInputImage(argv[1]);
std::cout<<"Loaded input images"<<std::endl;
/** construct curve */
//build multiplicity vector
std::vector<unsigned int> mPnts(5,1);
//build control point vectors
//x-values
Q[0]=38;
Q[1]=118;
Q[2]=133;
Q[3]=71;
Q[4]=27;
//y-values
Q[5]=125;
Q[6]=128;
Q[7]=45;
Q[8]=11;
Q[9]=77;
std::cout<<"Initing curve:"<<std::endl;
bspline_.Init(3, BIAS::ContourBSplineType::Closed, mPnts, Q);
std::cout<<"Inited curve:"<<std::endl;
bspline_.SetDrawSampleWidth(0.01);
bspline_.DrawCurve(imgDraw_, blue_);
std::cout<<"Drawn curve:"<<std::endl;
return 0;
}