]> Creatis software - FrontAlgorithms.git/blob - appli/examples/example_ImageAlgorithmRegionGrow_00.cxx
...
[FrontAlgorithms.git] / appli / examples / example_ImageAlgorithmRegionGrow_00.cxx
1 #include <iostream>
2 #include <itkImage.h>
3
4 #include <fpa/Image/RegionGrow.h>
5 #include <fpa/Image/Functors/RegionGrowAllBelongsFunction.h>
6
7 // -------------------------------------------------------------------------
8 const unsigned int Dim = 2;
9 typedef unsigned char TPixel;
10 typedef itk::Image< TPixel, Dim > TImage;
11
12 typedef fpa::Image::RegionGrow< TImage > TFrontAlgorithm;
13 typedef
14 fpa::Image::Functors::RegionGrowAllBelongsFunction< TImage >
15 TMembershipFunction;
16
17 // -------------------------------------------------------------------------
18 int main( int argc, char* argv[] )
19 {
20   // Create a dummy image
21   TImage::SizeType imageSize;
22   imageSize.Fill( 10 );
23
24   TImage::SpacingType imageSpacing;
25   imageSpacing.Fill( 1 );
26
27   TImage::Pointer image = TImage::New( );
28   image->SetRegions( imageSize );
29   image->SetSpacing( imageSpacing );
30   image->Allocate( );
31   image->FillBuffer( TPixel( 1 ) );
32
33   // Seed
34   TImage::IndexType seed;
35   seed.Fill( 5 );
36
37   // Configure membership function
38   TMembershipFunction::Pointer membership = TMembershipFunction::New( );
39
40   // Configure algorithm
41   TFrontAlgorithm::Pointer algorithm = TFrontAlgorithm::New( );
42   algorithm->AddSeed( seed, 0 );
43   algorithm->SetInput( image );
44   algorithm->SetNeighborhoodOrder( 1 );
45   algorithm->SetMembershipFunction( membership );
46   algorithm->Update( );
47
48   return( 0 );
49 }
50
51 // eof - $RCSfile$