1 #ifndef __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__
2 #define __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__
5 #include <vnl/vnl_math.h>
6 #include <itkLineConstIterator.h>
8 // -------------------------------------------------------------------------
9 template< class _TGradient >
10 fpa::Image::Functors::FluxMedialness< _TGradient >::
13 m_MinRadius( double( 0 ) ),
14 m_MaxRadius( double( 1 ) ),
15 m_RadialSampling( 4 ),
16 m_RadiusStep( double( 1 ) )
20 // -------------------------------------------------------------------------
21 template< class _TGradient >
22 fpa::Image::Functors::FluxMedialness< _TGradient >::
27 // -------------------------------------------------------------------------
28 template< class _TGradient >
29 typename fpa::Image::Functors::FluxMedialness< _TGradient >::
30 TOutput fpa::Image::Functors::FluxMedialness< _TGradient >::
31 _Evaluate( const TIndex& i ) const
33 itk::Object::GlobalWarningDisplayOff( );
35 double pi2n = double( 2 ) * double( vnl_math::pi );
36 pi2n /= int( this->m_RadialSampling );
37 const _TGradient* img = this->GetInputImage( );
38 // Gradient in central pixel
39 //TVector grad_idx = img->GetPixel( i );
44 TRCandidates FluxFinal;
45 TRCandidates radiusGenerated;
46 double dR = double( 0 );
47 double optR = double( 0 );
49 img->TransformIndexToPhysicalPoint( i, center );
50 double radius = double(0);
52 for( unsigned int cx = 0; cx < Self::Dimension - 1; cx++ )
54 for( unsigned int cy = cx + 1; cy < Self::Dimension; cy++ )
58 radiusGenerated.clear();
59 radius = this->m_MinRadius;
60 while( radius <= this->m_MaxRadius )
63 for( unsigned int I_radial = 0; I_radial < this->m_RadialSampling ; I_radial++ )
67 // Direction of first profile
68 typename TPoint::VectorType dir1;
69 dir1.Fill( double( 0 ) );
70 dir1[ cx ] = std::cos( pi2n * double( I_radial ) );
71 dir1[ cy ] = std::sin( pi2n * double( I_radial ) );
74 if (img->TransformPhysicalPointToIndex( center + dir1, rIdx ))
76 TVector grad_rIdx = img->GetPixel( rIdx );
78 u_i1.SetVnlVector( ( center - ( center + dir1 ) ).GetVnlVector( ) );
81 Flux1 = grad_rIdx * u_i1;
87 //std::cout<<" radius:"<<radius<<std::endl;
88 //std::cout<<"Center:"<<center[0]<<" "<<center[1]<<std::endl;
89 //std::cout<<"edge:"<<center[0]+radius*std::cos( pi2n * double( 0 ) )<<std::endl;
90 Flux /= this->m_RadialSampling;
91 FluxFinal.push_back(Flux);
92 radiusGenerated.push_back(radius);
93 radius += this->m_RadiusStep;
97 dR= *( std::max_element( FluxFinal.begin(), FluxFinal.end() ) );
98 optR= (dR>optR)? dR:optR;
103 return( TScalar(optR) );
106 #endif // __FPA__IMAGE__FUNCTORS__FLUXMEDIALNESS__HXX__