Example of tutorial 1: Local morphological opening of a 3d volume by the Fast Marching Method
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigExamples.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/images/ImageContainerBySTLMap.h"
#include "DGtal/base/BasicFunctors.h"
#include "DGtal/kernel/BasicPointPredicates.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/writers/VolWriter.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/helpers/FrontierPredicate.h"
#include "DGtal/topology/LightExplicitDigitalSurface.h"
#include "DGtal/geometry/volumes/distance/FMM.h"
using namespace Z3i;
int main(
int argc,
char** argv )
{
for ( int i = 0; i < argc; ++i )
trace.
info() <<
" " << argv[ i ];
string imageFileName = examplesPath + "samples/cat10.vol";
trace.
info() << imageFileName <<std::endl;
KSpace::SCell bel;
try {
trace.
info() <<
"starting bel: " << bel << std::endl;
trace.
emphase() <<
"starting bel not found" << std::endl;
return 0;
}
std::pair<Point,Point> bpair = toIncidentPoints( bel );
SurfelPredicate surfelPredicate( ks, binaryImage,
binaryImage( bpair.first ),
binaryImage( bpair.second ) );
Frontier frontier( ks, surfelPredicate,
const double maximalDistance = 3.0;
DistanceImage imageDistance(
domain, 0.0 );
AcceptedPointSet pointSet( imageDistance );
for (Frontier::SurfelConstIterator it = frontier.begin(), itEnd = frontier.end();
it != itEnd; ++it)
{
pointSet.insert( toInnerPoint(*it) );
imageDistance.setValue( toInnerPoint(*it), 0.5 );
}
FMM fmm( imageDistance, pointSet, binaryImage,
domain.size(), maximalDistance );
trace.
info() << fmm << std::endl;
trace.
info() <<
"Erosion of radius: " << maximalDistance << std::endl;
for (AcceptedPointSet::ConstIterator it = pointSet.begin(), itEnd = pointSet.end();
it != itEnd; ++it)
{
binaryImage.setValue(*it, 0);
}
string outputFileName = "eroded.vol";
trace.
info() <<
"to " << outputFileName << std::endl;
return 0;
}
Aim: An adapter for viewing an associative image container like ImageContainerBySTLMap as a simple di...
Aim: Fast Marching Method (FMM) for nd distance transforms.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
Aim: The predicate on surfels that represents the frontier between two regions in an image....
Aim: transforms a signed cell c into a pair of points corresponding to the signed cells of greater di...
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: implements methods to read a "Vol" file format.
Aim: Export a 3D Image using the Vol formats.
HyperRectDomain< Space > Domain