hey friends,
when I try to use itk::GradientAnisotropicDiffusionImageFilter
, I get a weird error saying:
RuntimeError: /Users/ncullen/desktop/PROJECTS/ANTsX/ANTsPy/itksource/Modules/Filtering/AnisotropicSmoothing/include/itkAnisotropicDiffusionImageFilter.hxx:52:
Anisotropic diffusion function is not set.
I’m basically just trying the example here … so maybe it’s an issue with my build?
I’m using itktag c5138560409c75408ff76bccff938f21e5dcafc6
and here is my itk cmake:
cmake \
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -Wno-c++11-long-long -fPIC -O2 -DNDEBUG "\
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wno-c++11-long-long -fPIC -O2 -DNDEBUG "\
-DITK_USE_GIT_PROTOCOL:BOOL=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DBUILD_EXAMPLES:BOOL=OFF \
-DCMAKE_INSTALL_PREFIX:PATH=${R_PACKAGE_DIR}/libs/ \
-DITK_LEGACY_REMOVE:BOOL=OFF \
-DITK_FUTURE_LEGACY_REMOVE:=BOOL=ON \
-DITKV3_COMPATIBILITY:BOOL=ON \
-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF \
-DKWSYS_USE_MD5:BOOL=ON \
-DITK_WRAPPING:BOOL=OFF \
-DModule_MGHIO:BOOL=ON \
-DModule_ITKDeprecated:BOOL=OFF \
-DModule_ITKReview:BOOL=ON \
-DModule_ITKVtkGlue:BOOL=ON \
-DModule_ITKAnisotropicSmoothing:BOOL=ON \
-D ITKGroup_Core=ON \
-D Module_ITKReview=ON \
-D ITKGroup_Filtering=ON \
-D ITKGroup_IO=ON \
-D ITKGroup_Numerics=ON \
-D ITKGroup_Registration=ON \
-D ITKGroup_Segmentation=ON \
-DCMAKE_C_VISIBILITY_PRESET:BOOL=hidden \
-DCMAKE_CXX_VISIBILITY_PRESET:BOOL=hidden \
-DCMAKE_VISIBILITY_INLINES_HIDDEN:BOOL=ON ../itksource/
code looks like this:
template <typename ImageType>
ImageType::Pointer locallyBlurImage( typename ImageType::Pointer itkImage, unsigned long nIterations,
double conductance )
{
typedef itk::GradientAnisotropicDiffusionImageFilter< ImageType, ImageType >FilterType;
typedef typename FilterType::TimeStepType TimeStepType;
// Select time step size.
TimeStepType spacingsize = 0;
for( unsigned int d = 0; d < ImageType::ImageDimension; d++ )
{
TimeStepType sp = itkImage->GetSpacing()[d];
spacingsize += sp * sp;
}
spacingsize = sqrt( spacingsize );
// FIXME - cite reason for this step
double dimPlusOne = ImageType::ImageDimension + 1;
TimeStepType mytimestep = spacingsize / std::pow( 2.0 , dimPlusOne );
TimeStepType reftimestep = 0.4 / std::pow( 2.0 , dimPlusOne );
if ( mytimestep > reftimestep )
{
mytimestep = reftimestep;
}
typename FilterType::Pointer filter = FilterType::New();
filter->SetInput( itkImage );
filter->SetConductanceParameter( conductance ); // might need to change this
filter->SetNumberOfIterations( nIterations );
filter->SetTimeStep( mytimestep );
filter->Update();
return filter->GetOutput();
}
Thanks
nick