本文整理汇总了C++中BinaryImage::domain方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryImage::domain方法的具体用法?C++ BinaryImage::domain怎么用?C++ BinaryImage::domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryImage
的用法示例。
在下文中一共展示了BinaryImage::domain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
DGtal::trace.info() << "2d interface evolution using DGtal ";
DGtal::trace.emphase() << "(version "<< DGTAL_VERSION << ")"<< std::endl;
// parse command line ----------------------------------------------
po::options_description general_opt("Allowed options are");
general_opt.add_options()
("help,h", "display this message")
("inputImage,i", po::value<string>(), "Binary image to initialize the starting interface (.pgm)" )
("domainSize,s", po::value<int>()->default_value(64), "Domain size (if default starting interface)" )
("timeStep,t", po::value<double>()->default_value(1.0), "Time step for the evolution" )
("displayStep,d", po::value<int>()->default_value(1), "Number of time steps between 2 drawings" )
("stepsNumber,n", po::value<int>()->default_value(1), "Maximal number of steps" )
("algo,a", po::value<string>()->default_value("levelSet"),
"can be: \n <levelSet> \n or <phaseField> " )
("balloonForce,k", po::value<double>()->default_value(0.0), "Balloon force" )
("epsilon,e", po::value<double>()->default_value(3.0), "Interface width (only for phase fields)" )
("withCstVol", "with volume conservation (only for phase fields)" )
("withFunction", po::value<string>(), "Output pgm file basename, where the starting implicit function is stored" )
("outputFiles,o", po::value<string>()->default_value("interface"), "Output files basename" )
("outputFormat,f", po::value<string>()->default_value("raster"),
"Output files format: either <raster> (image, default) or <vector> (domain representation)" );
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, general_opt), vm);
po::notify(vm);
if(vm.count("help")||argc<=1)
{
trace.info()<< "Evolution of a 2d interface" << std::endl
<< "Basic usage: "<<std::endl
<< argv[0] << " [other options] -t <time step> -n <number of steps>" << std::endl
<< general_opt << "\n";
return 0;
}
//Parse options
//domain size
int dsize;
if (!(vm.count("domainSize"))) trace.info() << "Domain size default value: 64" << std::endl;
dsize = vm["domainSize"].as<int>();
//time step
double tstep;
if (!(vm.count("timeStep"))) trace.info() << "time step default value: 1.0" << std::endl;
tstep = vm["timeStep"].as<double>();
//iterations
int step;
if (!(vm.count("displayStep"))) trace.info() << "number of steps between two drawings: 1 by default" << std::endl;
step = vm["displayStep"].as<int>();
int max;
if (!(vm.count("stepsNumber"))) trace.info() << "maximal number of steps: 1 by default" << std::endl;
max = vm["stepsNumber"].as<int>();
//files
std::string outputFiles;
if (!(vm.count("outputFiles")))
trace.info() << "output files beginning with : interface" << std::endl;
outputFiles = vm["outputFiles"].as<std::string>();
//files format
std::string format;
if (!(vm.count("outputFormat")))
trace.info() << "output files format is 'vector' " << std::endl;
format = vm["outputFormat"].as<std::string>();
if ((format != "vector")&&(format != "raster"))
{
trace.info() << "format is expected to be either vector, or raster " << std::endl;
return 0;
}
//balloon force
double k;
if (!(vm.count("balloonForce"))) trace.info() << "balloon force default value: 0" << std::endl;
k = vm["balloonForce"].as<double>();
//image and implicit function
Point p(0,0);
Point q(dsize,dsize);
Point c(dsize/2,dsize/2);
ImageContainerBySTLVector<Domain,double> implicitFunction( Domain(p,q) );
//initWithBall( implicitFunction, c, (dsize*3/5)/2 );
initWithFlower( implicitFunction, c, (dsize*3/5)/2, (dsize*1/5)/2, 5 );
if (!(vm.count("inputImage")))
trace.info() << "starting interface initialized with a flower shape" << std::endl;
else
{
string imageFileName = vm["inputImage"].as<std::string>();
trace.emphase() << imageFileName <<std::endl;
typedef ImageContainerBySTLVector<Domain,unsigned char> BinaryImage;
BinaryImage img = PNMReader<BinaryImage>::importPGM( imageFileName );
Domain d = img.domain();
implicitFunction = ImageContainerBySTLVector<Domain,double>( d );
initWithDT( img, implicitFunction );
}
//.........这里部分代码省略.........
示例2: main
int main( int argc, char** argv )
{
trace.beginBlock ( "Example FMMErosion" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
DGtal::trace.beginBlock("image reading...");
//! [FMMErosionImageReading]
string imageFileName = examplesPath + "samples/cat10.vol";
trace.info() << imageFileName <<std::endl;
typedef ImageContainerBySTLVector<Domain, bool> BinaryImage;
BinaryImage binaryImage = VolReader<BinaryImage>::importVol( imageFileName);
//! [FMMErosionImageReading]
DGtal::trace.endBlock();
DGtal::trace.beginBlock("Search for a bel...");
//space and starting bel
//! [FMMErosionStartingBel]
KSpace ks;
Domain domain = binaryImage.domain();
ks.init( domain.lowerBound(), domain.upperBound(), true );
KSpace::SCell bel;
try {
//getting a bel
bel = Surfaces<KSpace>::findABel( ks, binaryImage, domain.size() );
trace.info() << "starting bel: " << bel << std::endl;
} catch (DGtal::InputException i) {
trace.emphase() << "starting bel not found" << std::endl;
return 0;
}
//! [FMMErosionStartingBel]
DGtal::trace.endBlock();
DGtal::trace.beginBlock("Implicit frontier...");
//implicit frontier
//! [FMMErosionTracking]
typedef functors::FrontierPredicate<KSpace, BinaryImage> SurfelPredicate;
typedef LightExplicitDigitalSurface<KSpace, SurfelPredicate> Frontier;
functors::SCellToIncidentPoints<KSpace> toIncidentPoints( ks );
std::pair<Point,Point> bpair = toIncidentPoints( bel );
SurfelPredicate surfelPredicate( ks, binaryImage,
binaryImage( bpair.first ),
binaryImage( bpair.second ) );
Frontier frontier( ks, surfelPredicate,
SurfelAdjacency<KSpace::dimension>( true ), bel );
//! [FMMErosionTracking]
DGtal::trace.endBlock();
const double maximalDistance = 3.0;
DGtal::trace.beginBlock("FMM...");
//! [FMMErosionFMMTypes]
typedef ImageContainerBySTLMap<Domain,double> DistanceImage;
typedef DigitalSetFromMap<DistanceImage> AcceptedPointSet;
typedef FMM<DistanceImage, AcceptedPointSet, BinaryImage > FMM;
//! [FMMErosionFMMTypes]
//! [FMMErosionFMMInit]
DistanceImage imageDistance( domain, 0.0 );
AcceptedPointSet pointSet( imageDistance );
functors::SCellToInnerPoint<KSpace> toInnerPoint( ks );
for (Frontier::SurfelConstIterator it = frontier.begin(), itEnd = frontier.end();
it != itEnd; ++it)
{
pointSet.insert( toInnerPoint(*it) );
imageDistance.setValue( toInnerPoint(*it), 0.5 );
}
//! [FMMErosionFMMInit]
//! [FMMErosionFMM]
FMM fmm( imageDistance, pointSet, binaryImage,
domain.size(), maximalDistance );
fmm.compute();
trace.info() << fmm << std::endl;
//! [FMMErosionFMM]
DGtal::trace.endBlock();
DGtal::trace.beginBlock("Erosion");
trace.info() << "Erosion of radius: " << maximalDistance << std::endl;
//! [FMMErosionErosion]
for (AcceptedPointSet::ConstIterator it = pointSet.begin(), itEnd = pointSet.end();
it != itEnd; ++it)
{
binaryImage.setValue(*it, 0);
}
//! [FMMErosionErosion]
//.........这里部分代码省略.........