1 #include <Experiments/InsertNoiseIntoPoints.h>
2 #include <cpInstances/Image.h>
5 #include <vtkImageData.h>
6 #include <vtkPolyData.h>
7 #error http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution
8 // -------------------------------------------------------------------------
9 fpaPluginsExperiments::InsertNoiseIntoPoints::
10 InsertNoiseIntoPoints( )
13 typedef cpInstances::Image _TImage;
14 typedef cpPlugins::BaseObjects::DataObject _TData;
16 this->_ConfigureInput< _TData >( "Seeds", true, false );
17 this->_ConfigureInput< _TImage >( "DistanceMap", true, false );
18 this->_ConfigureOutput< _TData >( "Output" );
19 this->m_Parameters.ConfigureAsUint( "NumberOfSamples", 0 );
22 // -------------------------------------------------------------------------
23 fpaPluginsExperiments::InsertNoiseIntoPoints::
24 ~InsertNoiseIntoPoints( )
28 // -------------------------------------------------------------------------
29 void fpaPluginsExperiments::InsertNoiseIntoPoints::
32 auto dmap = this->GetInputData< vtkImageData >( "DistanceMap" );
33 auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
34 for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
36 double buf[ 3 ], pcoords[ 3 ];
37 seeds->GetPoint( i, buf );
39 dmap->ComputeStructuredCoordinates( buf, ijk, pcoords );
41 dmap->GetScalarComponentAsDouble( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 );
46 cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 )
47 this->_Error( "Invalid input image." );
51 // -------------------------------------------------------------------------
53 template< class _TImage >
54 void fpaPluginsExperiments::InsertNoiseIntoPoints::
55 _GD0( _TImage* image )
57 typedef fpa::Image::InsertNoiseIntoPoints< _TImage > _TFilter;
58 auto filter = this->_CreateITK< _TFilter >( );
59 filter->SetInput( image );
63 typename _TImage::PointType pnt;
64 typename _TImage::IndexType idx;
66 ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
68 for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
71 seeds->GetPoint( i, buf );
73 for( unsigned int d = 0; d < dim; ++d )
76 if( image->TransformPhysicalPointToIndex( pnt, idx ) )
77 filter->AddSeed( idx, 0 );
84 this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
85 this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );