From 60d343693f38ca042a14877fbf26c7c408765e06 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Wed, 4 Feb 2026 16:35:57 +0100 Subject: [PATCH] #3543 TubularStructures --- .../bbitkDetectTubularStructuresInImage.cxx | 12 + .../src/bbitkDetectTubularStructuresInImage.h | 135 +++++++++ ...kNormalizedCorrelationImageToImageMetric.h | 5 - packages/itk/src/bbitkResampleImageFilter.h | 4 +- .../itk/src/bbitkTubularStructures_Frangi.cxx | 12 + .../itk/src/bbitkTubularStructures_Frangi.h | 282 ++++++++++++++++++ .../itk/src/bbitkTubularStructures_Sato.cxx | 12 + .../itk/src/bbitkTubularStructures_Sato.h | 133 +++++++++ packages/vtk/src/bbvtkTemporalPicker.cxx | 28 +- packages/vtk/src/bbvtkUnaryOperations.cxx | 8 +- packages/vtk/src/bbvtkUnaryOperations.h | 6 - 11 files changed, 598 insertions(+), 39 deletions(-) create mode 100644 packages/itk/src/bbitkDetectTubularStructuresInImage.cxx create mode 100644 packages/itk/src/bbitkDetectTubularStructuresInImage.h create mode 100644 packages/itk/src/bbitkTubularStructures_Frangi.cxx create mode 100644 packages/itk/src/bbitkTubularStructures_Frangi.h create mode 100644 packages/itk/src/bbitkTubularStructures_Sato.cxx create mode 100644 packages/itk/src/bbitkTubularStructures_Sato.h diff --git a/packages/itk/src/bbitkDetectTubularStructuresInImage.cxx b/packages/itk/src/bbitkDetectTubularStructuresInImage.cxx new file mode 100644 index 0000000..98db8c3 --- /dev/null +++ b/packages/itk/src/bbitkDetectTubularStructuresInImage.cxx @@ -0,0 +1,12 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbitkDetectTubularStructuresInImage.h" +#include "bbitkPackage.h" +namespace bbitk +{ + BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,DetectTubularStructuresInImage) + BBTK_BLACK_BOX_IMPLEMENTATION(DetectTubularStructuresInImage,bbtk::AtomicBlackBox); +} // EO namespace bbitk + + diff --git a/packages/itk/src/bbitkDetectTubularStructuresInImage.h b/packages/itk/src/bbitkDetectTubularStructuresInImage.h new file mode 100644 index 0000000..fc05753 --- /dev/null +++ b/packages/itk/src/bbitkDetectTubularStructuresInImage.h @@ -0,0 +1,135 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbitkDetectTubularStructuresInImage_h_INCLUDED__ +#define __bbitkDetectTubularStructuresInImage_h_INCLUDED__ + +#include "bbitk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "itkHessian3DToVesselnessMeasureImageFilter.h" +#include "itkHessianRecursiveGaussianImageFilter.h" + +#include "bbitkImage.h" + +namespace bbitk +{ + +class bbitk_EXPORT DetectTubularStructuresInImage + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(DetectTubularStructuresInImage,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(In,anyImagePointer); + BBTK_DECLARE_INPUT(Sigma,double); + BBTK_DECLARE_INPUT(Alpha1,double); + BBTK_DECLARE_INPUT(Alpha2,double); + BBTK_DECLARE_OUTPUT(Out,anyImagePointer); + BBTK_PROCESS(ProcessSwitch); + + private : + inline void ProcessSwitch(); + template void Process(); + itk::Object* mOutput; + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(DetectTubularStructuresInImage,bbtk::AtomicBlackBox); + BBTK_NAME("DetectTubularStructuresInImage"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("detect bright tubular structures in the image"); + BBTK_CATEGORY("empty"); + BBTK_INPUT(DetectTubularStructuresInImage,In,"Input image",anyImagePointer,""); + BBTK_INPUT(DetectTubularStructuresInImage,Sigma,"(default 1) hessianFilter Sigma",double,""); + BBTK_INPUT(DetectTubularStructuresInImage,Alpha1,"(default 0.5) vesselnessFilter Alpha1",double,""); + BBTK_INPUT(DetectTubularStructuresInImage,Alpha2,"(default 2.0) vesselnessFilter Alpha2",double,""); + BBTK_OUTPUT(DetectTubularStructuresInImage,Out,"Output image",anyImagePointer,""); +BBTK_END_DESCRIBE_BLACK_BOX(DetectTubularStructuresInImage); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + +//=================================================== +void DetectTubularStructuresInImage::ProcessSwitch() +{ + bbtk::TypeInfo t = bbGetInputIn().type(); +// BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process); +// BBTK_TEMPLATE_ITK_IMAGE_DIM_3_SWITCH(t, this->Process , "Error format. (you need 3D short,float,double)") ; + + BBTK_BEGIN_TEMPLATE_SWITCH(t) +// BBTK_SWITCH_ITK_IMAGE_short_3(t,this->Process,) +// BBTK_SWITCH_ITK_IMAGE_float_3(t,this->Process,) + BBTK_SWITCH_ITK_IMAGE_double_3(t,this->Process,) + BBTK_END_TEMPLATE_SWITCH(t) +} + + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +template +void DetectTubularStructuresInImage::Process() +{ + // https://docs.itk.org/projects/doxygen/en/stable/Examples_2Filtering_2VesselnessMeasureImageFilter_8cxx-example.html + // https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1HessianRecursiveGaussianImageFilter.html + // https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html + // http://www.image.med.osaka-u.ac.jp/member/yoshi/paper/linefilter.pdf + printf("EED DetectTubularStructuresInImage::Process Start\n"); + constexpr unsigned int Dimension = 3; + using InputPixelType = double; + using OutputPixelType = float; + using InputImageType = itk::Image; + using HessianFilterType = itk::HessianRecursiveGaussianImageFilter; + using VesselnessMeasureFilterType = itk::Hessian3DToVesselnessMeasureImageFilter; + auto hessianFilter = HessianFilterType::New(); + auto vesselnessFilter = VesselnessMeasureFilterType::New(); + T* inputImage = this->bbGetInputIn().get(); + hessianFilter->SetInput( inputImage ); + hessianFilter->SetSigma(static_cast( bbGetInputSigma() )); + vesselnessFilter->SetInput(hessianFilter->GetOutput()); + vesselnessFilter->SetAlpha1(static_cast( bbGetInputAlpha1() )); + vesselnessFilter->SetAlpha2(static_cast( bbGetInputAlpha2() )); + vesselnessFilter->Update(); + vesselnessFilter->GetOutput()->Register(); + if (mOutput) mOutput->UnRegister(); + this->bbSetOutputOut( vesselnessFilter->GetOutput() ); + mOutput = vesselnessFilter->GetOutput(); + printf("EED DetectTubularStructuresInImage::Process End\n"); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void DetectTubularStructuresInImage::bbUserSetDefaultValues() +{ + mOutput = 0; + bbSetInputSigma(1); + bbSetInputAlpha1(0.5); + bbSetInputAlpha2(2.0); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void DetectTubularStructuresInImage::bbUserInitializeProcessing() +{ +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void DetectTubularStructuresInImage::bbUserFinalizeProcessing() +{ +} + +}// EO namespace bbitk + +#endif // __bbitkDetectTubularStructuresInImage_h_INCLUDED__ + diff --git a/packages/itk/src/bbitkNormalizedCorrelationImageToImageMetric.h b/packages/itk/src/bbitkNormalizedCorrelationImageToImageMetric.h index c4d30bc..c3e4068 100644 --- a/packages/itk/src/bbitkNormalizedCorrelationImageToImageMetric.h +++ b/packages/itk/src/bbitkNormalizedCorrelationImageToImageMetric.h @@ -13,11 +13,9 @@ #include "itkRescaleIntensityImageFilter.h" #include "itkMinimumMaximumImageCalculator.h" - #include #include - namespace bbitk { @@ -36,7 +34,6 @@ class bbitk_EXPORT NormalizedCorrelationImageToImageMetric private : inline void ProcessSwitch(); template void Process(); - //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -86,7 +83,6 @@ BBTK_END_DESCRIBE_BLACK_BOX(NormalizedCorrelationImageToImageMetric); correlationFilter->SetMovingImage( in2 ); correlationFilter->Update(); - using RescaleFilterType = itk::RescaleIntensityImageFilter; auto rescaleFilter = RescaleFilterType::New(); rescaleFilter->SetInput(correlationFilter->GetOutput()); @@ -113,7 +109,6 @@ BBTK_END_DESCRIBE_BLACK_BOX(NormalizedCorrelationImageToImageMetric); this->bbSetOutputOut( minimumMaximumImageCalculatorFilter->GetMaximum() ); printf("EED NormalizedCorrelationImageToImageMetric::Process End \n"); - } //----------------------------------------------------------------- diff --git a/packages/itk/src/bbitkResampleImageFilter.h b/packages/itk/src/bbitkResampleImageFilter.h index ffead94..67c0184 100644 --- a/packages/itk/src/bbitkResampleImageFilter.h +++ b/packages/itk/src/bbitkResampleImageFilter.h @@ -116,8 +116,8 @@ namespace bbitk LPR = in->GetLargestPossibleRegion(); size = LPR.GetSize(); // origin = LPR.GetIndex(); //in->GetOrigin(); - for (unsigned int i=0;iGetSpacing()[i]; spacing[i] = bbGetInputSpacing()[i]; double tmp = (LPR.GetSize()[i]*in->GetSpacing()[i]/spacing[i] ) + 0.5; diff --git a/packages/itk/src/bbitkTubularStructures_Frangi.cxx b/packages/itk/src/bbitkTubularStructures_Frangi.cxx new file mode 100644 index 0000000..b1c0102 --- /dev/null +++ b/packages/itk/src/bbitkTubularStructures_Frangi.cxx @@ -0,0 +1,12 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbitkTubularStructures_Frangi.h" +#include "bbitkPackage.h" +namespace bbitk +{ + BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,TubularStructures_Frangi) + BBTK_BLACK_BOX_IMPLEMENTATION(TubularStructures_Frangi,bbtk::AtomicBlackBox); +} // EO namespace bbitk + + diff --git a/packages/itk/src/bbitkTubularStructures_Frangi.h b/packages/itk/src/bbitkTubularStructures_Frangi.h new file mode 100644 index 0000000..4666d26 --- /dev/null +++ b/packages/itk/src/bbitkTubularStructures_Frangi.h @@ -0,0 +1,282 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbitkTubularStructures_Frangi_h_INCLUDED__ +#define __bbitkTubularStructures_Frangi_h_INCLUDED__ + +#include "bbitk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "itkImage.h" +//#include "itkImageFileReader.h" +//#include "itkImageFileWriter.h" +#include "itkExtractImageFilter.h" + +#include "itkHessianToObjectnessMeasureImageFilter.h" +#include "itkMultiScaleHessianBasedMeasureImageFilter.h" +#include "itkRescaleIntensityImageFilter.h" + +#include "bbitkImage.h" + +namespace bbitk +{ + +class bbitk_EXPORT TubularStructures_Frangi +: +public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(TubularStructures_Frangi,bbtk::AtomicBlackBox); + //===== + // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) + //===== + BBTK_DECLARE_INPUT(In,anyImagePointer); + + // 3 - alpha + // 4 - beta + // 5 - gamma + // 6 - sigmaMinimum + // 7 - sigmaMaximum + // 8 - numberOfSigmaSteps + BBTK_DECLARE_INPUT(Alpha,double); + BBTK_DECLARE_INPUT(Beta,double); + BBTK_DECLARE_INPUT(Gamma,double); + BBTK_DECLARE_INPUT(SigmaMinimum,double); + BBTK_DECLARE_INPUT(SigmaMaximum,double); + BBTK_DECLARE_INPUT(NumberOfSigmaSteps,int); + + BBTK_DECLARE_OUTPUT(Out,anyImagePointer); + BBTK_PROCESS(ProcessSwitch); + private : + inline void ProcessSwitch(); + template void Process(); + itk::Object* mOutput; + //===== + // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) + //===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(TubularStructures_Frangi,bbtk::AtomicBlackBox); + BBTK_NAME("TubularStructures_Frangi"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(TubularStructures_Frangi,In,"First input in DOUBLE format",anyImagePointer,""); + BBTK_INPUT(TubularStructures_Frangi,Alpha,"(default 0.8) Alpha",double,""); + BBTK_INPUT(TubularStructures_Frangi,Beta,"(default 1) Beta",double,""); + BBTK_INPUT(TubularStructures_Frangi,Gamma,"(default 250) Gamma",double,""); + BBTK_INPUT(TubularStructures_Frangi,SigmaMinimum,"(default 0.5) SigmaMinimum",double,""); + BBTK_INPUT(TubularStructures_Frangi,SigmaMaximum,"(default 12) SigmaMaximum",double,""); + BBTK_INPUT(TubularStructures_Frangi,NumberOfSigmaSteps,"(default 11) NumberOfSigmaSteps",int,""); + BBTK_OUTPUT(TubularStructures_Frangi,Out,"First output in DOUBLE format",anyImagePointer,""); +BBTK_END_DESCRIBE_BLACK_BOX(TubularStructures_Frangi); + +//=================================================== +void TubularStructures_Frangi::ProcessSwitch() +{ + bbtk::TypeInfo t = bbGetInputIn().type(); +// BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process); +// BBTK_TEMPLATE_ITK_IMAGE_DIM_3_SWITCH(t, this->Process , "Error format. (you need 3D short,float,double)") ; + + BBTK_BEGIN_TEMPLATE_SWITCH(t) +// BBTK_SWITCH_ITK_IMAGE_short_3(t,this->Process,) +// BBTK_SWITCH_ITK_IMAGE_float_3(t,this->Process,) + BBTK_SWITCH_ITK_IMAGE_double_3(t,this->Process,) + BBTK_END_TEMPLATE_SWITCH(t) +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +template +void TubularStructures_Frangi::Process() +{ + printf("EED TubularStructures_Frangi::Process Start\n"); + +// std::cout << "Starting Hessian filter" << std::endl; + +// if (argc > 9){ +// std::cout << "too many arguments" << std::endl; +// return EXIT_FAILURE; +// } + + // setting up arguments +// std::string filename, filetype; + float alpha, beta, gamma; + double sigmaMinimum, sigmaMaximum; + unsigned int numberOfSigmaSteps; + // constexpr, computation at compile time + constexpr unsigned int Dimension = 3; + constexpr float desiredMinimum = 0.0; + constexpr float desiredMaximum = 255.0; + +// if (argc == 9){ +// filename = argv[1]; +// filetype = argv[2]; +// alpha = std::stof(argv[3]); +// beta = std::stof(argv[4]); +// gamma = std::stof(argv[5]); +// sigmaMinimum = std::atof(argv[6]); +// sigmaMaximum = std::atof(argv[7]); +// numberOfSigmaSteps = atoi(argv[8]); +// } else { +// std::cout << "Not enough arguments, went with default" << std::endl; +// filename = "Smallfield_OCT_Angiography_Volume_fovea"; //filename in data/ +// filetype = ".nii"; +// alpha = 0.8; +// beta = 1; +// gamma = 250; +// sigmaMinimum = 0.5; +// sigmaMaximum = 12; +// numberOfSigmaSteps = 11; +// } + + alpha = bbGetInputAlpha(); + beta = bbGetInputBeta(); + gamma = bbGetInputGamma(); + sigmaMinimum = bbGetInputSigmaMinimum(); + sigmaMaximum = bbGetInputSigmaMaximum(); + numberOfSigmaSteps = bbGetInputNumberOfSigmaSteps(); + + //timing +// auto start = std::chrono::high_resolution_clock::now(); +// std::string inputFileName = makeInputFileName(filename, filetype); +// auto stop = std::chrono::high_resolution_clock::now(); +// auto duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for reading in the file and creating constants"<; +// using ReaderType = itk::ImageFileReader< ImageType >; + + //Setting up the reader +// ReaderType::Pointer reader = ReaderType::New(); +// reader->SetFileName( inputFileName ); +// reader->Update(); + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for setting image and reader"<GetOutput(); +// ImageType::RegionType region = image->GetLargestPossibleRegion(); + + T* inputImage = this->bbGetInputIn().get(); + // ImageType::RegionType region = image->GetLargestPossibleRegion(); + ImageType::RegionType region = inputImage->GetLargestPossibleRegion(); + ImageType::SizeType size = region.GetSize(); + + using HessianPixelType = itk::SymmetricSecondRankTensor< float, Dimension >; + using HessianImageType = itk::Image< HessianPixelType, Dimension >; + using ObjectnessFilterType = itk::HessianToObjectnessMeasureImageFilter< HessianImageType, ImageType >; + ObjectnessFilterType::Pointer objectnessFilter = ObjectnessFilterType::New(); + objectnessFilter->SetBrightObject( true ); + objectnessFilter->SetScaleObjectnessMeasure( false ); + objectnessFilter->SetAlpha( alpha ); + objectnessFilter->SetBeta( beta ); + objectnessFilter->SetGamma( gamma ); + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for setting Hessian output image"<; + MultiScaleEnhancementFilterType::Pointer multiScaleEnhancementFilter = MultiScaleEnhancementFilterType::New(); + +// multiScaleEnhancementFilter->SetInput( reader->GetOutput() ); + multiScaleEnhancementFilter->SetInput( inputImage ); + + multiScaleEnhancementFilter->SetHessianToMeasureFilter( objectnessFilter ); + multiScaleEnhancementFilter->SetSigmaStepMethodToLogarithmic(); + multiScaleEnhancementFilter->SetSigmaMinimum( sigmaMinimum ); + multiScaleEnhancementFilter->SetSigmaMaximum( sigmaMaximum ); + multiScaleEnhancementFilter->SetNumberOfSigmaSteps( numberOfSigmaSteps ); + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for setting up the Hessian filter" <; +// using RescaleFilterType = itk::RescaleIntensityImageFilter< ImageType, OutputImageType >; +// RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New(); +// rescaleFilter->SetInput( multiScaleEnhancementFilter->GetOutput() ); + + //rescale to 0 and 255 for output +// rescaleFilter->SetOutputMinimum(desiredMinimum); +// rescaleFilter->SetOutputMaximum(desiredMaximum); + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for setting min max intensity"<< std::endl; + + //Setting up the output writer +// using WriterType = itk::ImageFileWriter< OutputImageType >;//setting up type for writer +// WriterType::Pointer writer = WriterType::New();//initialize new writer pointer +// writer->SetFileName( outputFileName );//set filename for writer +// writer->SetInput( rescaleFilter->GetOutput() );// +//writer->SetUseCompression( true ); + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds for setting up writer" << std::endl; + + + //Write to file +// try { +// writer->Update(); +// } catch ( itk::ExceptionObject & error ){ +// std::cerr << "Error: " << error << std::endl; +// return EXIT_FAILURE; +// } + +// stop = std::chrono::high_resolution_clock::now(); +// duration = std::chrono::duration_cast(stop - start); +// std::cout << duration.count() << " milliseconds when " << outputFileName << " written out succesfully" << std::endl; +// return EXIT_SUCCESS; + + multiScaleEnhancementFilter->Update(); + multiScaleEnhancementFilter->GetOutput()->Register(); + if (mOutput) mOutput->UnRegister(); + this->bbSetOutputOut( multiScaleEnhancementFilter->GetOutput() ); + mOutput = multiScaleEnhancementFilter->GetOutput(); + + printf("EED TubularStructures_Frangi::Process End\n"); + +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Frangi::bbUserSetDefaultValues() +{ + bbSetInputAlpha( 0.8 ); + bbSetInputBeta( 1 ); + bbSetInputGamma( 250 ); + bbSetInputSigmaMinimum( 0.5 ); + bbSetInputSigmaMaximum( 12 ); + bbSetInputNumberOfSigmaSteps( 11 ); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Frangi::bbUserInitializeProcessing() +{ +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Frangi::bbUserFinalizeProcessing() +{ +} + +}// EO namespace bbitk +#endif // __bbitkTubularStructures_Frangi_h_INCLUDED__ + diff --git a/packages/itk/src/bbitkTubularStructures_Sato.cxx b/packages/itk/src/bbitkTubularStructures_Sato.cxx new file mode 100644 index 0000000..e20423c --- /dev/null +++ b/packages/itk/src/bbitkTubularStructures_Sato.cxx @@ -0,0 +1,12 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbitkTubularStructures_Sato.h" +#include "bbitkPackage.h" +namespace bbitk +{ + BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,TubularStructures_Sato) + BBTK_BLACK_BOX_IMPLEMENTATION(TubularStructures_Sato,bbtk::AtomicBlackBox); +} // EO namespace bbitk + + diff --git a/packages/itk/src/bbitkTubularStructures_Sato.h b/packages/itk/src/bbitkTubularStructures_Sato.h new file mode 100644 index 0000000..dcdae3e --- /dev/null +++ b/packages/itk/src/bbitkTubularStructures_Sato.h @@ -0,0 +1,133 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbitkTubularStructures_Sato_h_INCLUDED__ +#define __bbitkTubularStructures_Sato_h_INCLUDED__ + +#include "bbitk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "itkHessian3DToVesselnessMeasureImageFilter.h" +#include "itkHessianRecursiveGaussianImageFilter.h" + +#include "bbitkImage.h" + +namespace bbitk +{ + +class bbitk_EXPORT TubularStructures_Sato + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(TubularStructures_Sato,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(In,anyImagePointer); + BBTK_DECLARE_INPUT(Sigma,double); + BBTK_DECLARE_INPUT(Alpha1,double); + BBTK_DECLARE_INPUT(Alpha2,double); + BBTK_DECLARE_OUTPUT(Out,anyImagePointer); + BBTK_PROCESS(ProcessSwitch); + private : + inline void ProcessSwitch(); + template void Process(); + itk::Object* mOutput; +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(TubularStructures_Sato,bbtk::AtomicBlackBox); + BBTK_NAME("TubularStructures_Sato"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + + BBTK_INPUT(TubularStructures_Sato,In,"Input image in DOUBLE format",anyImagePointer,""); + BBTK_INPUT(TubularStructures_Sato,Sigma,"(default 1) hessianFilter Sigma",double,""); + BBTK_INPUT(TubularStructures_Sato,Alpha1,"(default 0.5) vesselnessFilter Alpha1",double,""); + BBTK_INPUT(TubularStructures_Sato,Alpha2,"(default 2.0) vesselnessFilter Alpha2",double,""); + BBTK_OUTPUT(TubularStructures_Sato,Out,"Output image in FLOAT format",anyImagePointer,""); + +BBTK_END_DESCRIBE_BLACK_BOX(TubularStructures_Sato); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + +//=================================================== +void TubularStructures_Sato::ProcessSwitch() +{ + bbtk::TypeInfo t = bbGetInputIn().type(); +// BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process); +// BBTK_TEMPLATE_ITK_IMAGE_DIM_3_SWITCH(t, this->Process , "Error format. (you need 3D short,float,double)") ; + + BBTK_BEGIN_TEMPLATE_SWITCH(t) +// BBTK_SWITCH_ITK_IMAGE_short_3(t,this->Process,) +// BBTK_SWITCH_ITK_IMAGE_float_3(t,this->Process,) + BBTK_SWITCH_ITK_IMAGE_double_3(t,this->Process,) + BBTK_END_TEMPLATE_SWITCH(t) +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +template +void TubularStructures_Sato::Process() +{ + // https://docs.itk.org/projects/doxygen/en/stable/Examples_2Filtering_2VesselnessMeasureImageFilter_8cxx-example.html + // https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1HessianRecursiveGaussianImageFilter.html + // https://docs.itk.org/projects/doxygen/en/stable/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html + // http://www.image.med.osaka-u.ac.jp/member/yoshi/paper/linefilter.pdf + printf("EED TubularStructures_Sato::Process Start\n"); + constexpr unsigned int Dimension = 3; + using InputPixelType = double; + using OutputPixelType = float; + using InputImageType = itk::Image< InputPixelType, Dimension >; + using HessianFilterType = itk::HessianRecursiveGaussianImageFilter< InputImageType >; + using VesselnessMeasureFilterType = itk::Hessian3DToVesselnessMeasureImageFilter< OutputPixelType >; + auto hessianFilter = HessianFilterType::New(); + auto vesselnessFilter = VesselnessMeasureFilterType::New(); + T* inputImage = this->bbGetInputIn().get(); + hessianFilter->SetInput( inputImage ); + hessianFilter->SetSigma(static_cast( bbGetInputSigma() )); + vesselnessFilter->SetInput(hessianFilter->GetOutput()); + vesselnessFilter->SetAlpha1(static_cast( bbGetInputAlpha1() )); + vesselnessFilter->SetAlpha2(static_cast( bbGetInputAlpha2() )); + vesselnessFilter->Update(); + vesselnessFilter->GetOutput()->Register(); + if (mOutput) mOutput->UnRegister(); + this->bbSetOutputOut( vesselnessFilter->GetOutput() ); + mOutput = vesselnessFilter->GetOutput(); + printf("EED TubularStructures_Sato::Process End\n"); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Sato::bbUserSetDefaultValues() +{ + mOutput = 0; + bbSetInputSigma(1); + bbSetInputAlpha1(0.5); + bbSetInputAlpha2(2.0); +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Sato::bbUserInitializeProcessing() +{ +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubularStructures_Sato::bbUserFinalizeProcessing() +{ +} + +}// EO namespace bbitk +#endif // __bbitkTubularStructures_Sato_h_INCLUDED__ + diff --git a/packages/vtk/src/bbvtkTemporalPicker.cxx b/packages/vtk/src/bbvtkTemporalPicker.cxx index f1375ac..02e1775 100644 --- a/packages/vtk/src/bbvtkTemporalPicker.cxx +++ b/packages/vtk/src/bbvtkTemporalPicker.cxx @@ -140,7 +140,6 @@ printf("EED Warnning !!!!!! TemporalPicker::Process Clean this method region bbSetOutputOut(result); } - //-------------------------------------------------------------------------------------------- void TemporalPicker::Process_TemporaryPicker2DT() { @@ -161,7 +160,6 @@ void TemporalPicker::Process_TemporaryPicker2DT() sizeY=ext[3]-ext[2]+1; sizeZ=ext[5]-ext[4]+1; - if (bbGetInputPoint().size()>=2) { int px=bbGetInputPoint()[0]; @@ -241,7 +239,6 @@ printf("EED Warnning !!!!!! TemporalPicker::Process Clean this method region void TemporalPicker::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -253,54 +250,47 @@ void TemporalPicker::Process() // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') - - if (bbGetInputInLst().size()>0) { Process_TemporaryPicker3DT(); } else { Process_TemporaryPicker2DT(); } - } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TemporalPicker::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn(NULL); bbSetInputSizeRegion(1); - } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TemporalPicker::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TemporalPicker::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbvtk + +}// EO namespace bbvtk diff --git a/packages/vtk/src/bbvtkUnaryOperations.cxx b/packages/vtk/src/bbvtkUnaryOperations.cxx index f2db953..efa7bad 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.cxx +++ b/packages/vtk/src/bbvtkUnaryOperations.cxx @@ -24,13 +24,11 @@ # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ - #include "bbvtkUnaryOperations.h" #include "bbvtkPackage.h" namespace bbvtk { - BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,UnaryOperations) BBTK_BLACK_BOX_IMPLEMENTATION(UnaryOperations,bbtk::AtomicBlackBox); void UnaryOperations::Process() @@ -61,7 +59,6 @@ void UnaryOperations::Process() ope->SetInput1Data((vtkDataObject*)bbGetInputIn1()); #endif - switch (bbGetInputOperation()) { case 0: @@ -111,10 +108,7 @@ printf("EED UnaryOperations::Process() 3 \n"); ope->SetConstantK( bbGetInputNewValue() ); ope->SetOperationToReplaceCByK(); break; - - - - + default: std::cout << "Invalid Operation" << std::endl; return; diff --git a/packages/vtk/src/bbvtkUnaryOperations.h b/packages/vtk/src/bbvtkUnaryOperations.h index d65d6f6..4b41786 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.h +++ b/packages/vtk/src/bbvtkUnaryOperations.h @@ -31,7 +31,6 @@ #include "bbtkAtomicBlackBox.h" #include "iostream" - #include "vtkVersion.h" #include #include @@ -39,13 +38,8 @@ #include #include - namespace bbvtk { - - - - class bbvtk_EXPORT UnaryOperations : public bbtk::AtomicBlackBox -- 2.52.0