Example for usage of class BlobDetectorLevelSet Usage: Simple start this program. The input: ExampleSegmentationLevelSet.pgm (a picture of Bodo Rosenhahn) The output: __orig.pgm, __set[000-070].pgm __lev.pgm
#include "../BlobDetectorLevelSet.hh"
#include <string>
#include <iostream>
#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Utils/Param.hh>
using namespace std;
using namespace BIAS;
const string name, const int id = -1)
{
stringstream num;
if(id>=0)
num<<name<<FileHandling::LeadingZeroString(3,id)<<".pgm";
else
num<<name<<".pgm";
ImageIO::Save(num.str(),
const_cast<ImageBase&
>(im), ImageIO::FF_pgm);
}
{
ImageIO::ImportImage(name, buf);
ImageConvert::ToGrey(buf, im);
}
void AddParams()
{
para->
AddParamBool(
"help",
"shows help on params",
false,
'h');
"./ExampleSegmentationLevelSet.pgm");
para->
AddParamString(
"o",
"output file of final level set",
"__lev",
'o');
"rectangle specifying level set "
"(overwhelmed by --level) [x1 y1 x2 y2]",
"rectangle specifying evaluation region "
"(overwhelmed by --eval) [x1 y1 x2 y2]",
vec0i(0) );
}
string GetStr(
const string param) {
return *para->
GetParamString(param); }
int GetInt(
const string param) {
return *para->
GetParamInt(param); }
vec2i GetVec(
const string param,
const int i,
const vec2i def =
vec2i(0,0)) {
cout << "KKKKKKKKKKKKK"<<GetVec(param)<<endl;
if ( (int)GetVec(param).Size() > i*2 )
return vec2i( GetVec(param).SubVec(2,i*2) );
else
return def;
}
int main(int args, char **arg)
{
cout << "starting..." << endl;
AddParams();
return 0;
}
ReadImage(image, GetStr("image"));
if ( GetStr("eval") != "" ) {
ReadImage(eval, GetStr("eval"));
}
if ( GetStr("level") != "" ) {
ReadImage(levelset, GetStr("level"));
}
if ( GetStr("eval") == "" )
GetVec(
"ev",1,
vec2i(w,h)) );
if ( GetStr("level") == "" )
GetVec(
"lv",1,
vec2i(w/4*3,h/4*3)) );
cout << "initialised." << endl;
WriteImage(lset.
GetImage(),
"./__image");
WriteImage(lset.
GetEval(),
"./__image_eval");
WriteImage(lset.
GetLevel(),
"./__image_level");
WriteImage(im_seg,"./__seg",0);
cout << "running." << endl;
for (int i = 1; i <= GetInt("n"); i++) {
cout << "Iteration: " << i << endl;
WriteImage(im_seg,"./__seg",i);
}
if ( GetStr("o") != "" )
WriteImage(lset.
GetLevel(), GetStr(
"o"));
cout << "done." << endl;
return 0;
}