Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/Bridge/VtkGlue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@ if(ENABLE_QUICKVIEW)
#compare_to_baseline(EXAMPLE_NAME VTKImageToITKImage
# BASELINE_PREFIX OutputBaseline
# )

if(ITK_VERSION_MAJOR LESS 5)
add_example(VisualizeEvolvingDense2DLevelSetAsElevationMap)
add_example(VisualizeEvolvingDense2DLevelSetZeroSet)
endif()
endif()

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/Bridge/VtkGlue/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ VtkGlue
ConvertAnRGBitkImageTovtkImageData/Documentation.rst
ConvertRGBvtkImageDataToAnitkImage/Documentation.rst
ConvertvtkImageDataToAnitkImage/Documentation.rst
VisualizeEvolvingDense2DLevelSetAsElevationMap/Documentation.rst
VisualizeEvolvingDense2DLevelSetZeroSet/Documentation.rst
VTKImageToITKImage/Documentation.rst
2 changes: 2 additions & 0 deletions src/Segmentation/LevelSetsv4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_example(VisualizeEvolvingDense2DLevelSetZeroSet)
add_example(VisualizeEvolvingDense2DLevelSetAsElevationMap)
add_example(VisualizeStaticDense2DLevelSetAsElevationMap)
add_example(VisualizeStaticDense2DLevelSetZeroSet)
add_example(VisualizeStaticWhitaker2DLevelSetLayers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_link_libraries(
install(
TARGETS
${PROJECT_NAME}
DESTINATION bin/ITKSphinxExamples/Bridge/VtkGlue
DESTINATION bin/ITKSphinxExamples/Segmentation/LevelSetsv4
COMPONENT Runtime
)

Expand All @@ -26,7 +26,7 @@ install(
Code.cxx
CMakeLists.txt
DESTINATION
share/ITKSphinxExamples/Code/Bridge/VtkGlue/VisualizeEvolvingDense2DLevelSetAsElevationMap
share/ITKSphinxExamples/Code/Segmentation/LevelSetsv4/VisualizeEvolvingDense2DLevelSetAsElevationMap
COMPONENT Code
)

Expand All @@ -35,7 +35,7 @@ add_test(
NAME VisualizeEvolvingDense2DLevelSetAsElevationMapTest
COMMAND
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}
${CMAKE_CURRENT_BINARY_DIR}/cells.png 100
${CMAKE_CURRENT_BINARY_DIR}/cells.png 100 Output.mha
)
set_tests_properties(
VisualizeEvolvingDense2DLevelSetAsElevationMapTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "itkBinaryImageToLevelSetImageAdaptor.h"
#include "itkImageFileReader.h"
#include "itkLevelSetIterationUpdateCommand.h"
#include "itkLevelSetContainer.h"
#include "itkLevelSetEquationChanAndVeseInternalTerm.h"
#include "itkLevelSetEquationChanAndVeseExternalTerm.h"
Expand All @@ -27,18 +26,19 @@
#include "itkLevelSetEvolution.h"
#include "itkLevelSetEvolutionNumberOfIterationsStoppingCriterion.h"
#include "itkLevelSetDenseImage.h"
#include "itkVTKVisualize2DLevelSetAsElevationMap.h"
#include "itkImageFileWriter.h"
#include "itkSinRegularizedHeavisideStepFunction.h"

int
main(int argc, char * argv[])
{
if (argc != 3)
if (argc != 4)
{
std::cerr << "Missing Arguments" << std::endl;
std::cerr << argv[0] << std::endl;
std::cerr << "1- Input Image" << std::endl;
std::cerr << "2- Number of Iterations" << std::endl;
std::cerr << "3- Output Image" << std::endl;
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -140,28 +140,24 @@ main(int argc, char * argv[])
auto criterion = StoppingCriterionType::New();
criterion->SetNumberOfIterations(numberOfIterations);

// Create the visualizer
using VisualizationType = itk::VTKVisualize2DLevelSetAsElevationMap<InputImageType, LevelSetType>;
auto visualizer = VisualizationType::New();
visualizer->SetInputImage(input);
visualizer->SetLevelSet(levelSet);
visualizer->SetScreenCapture(true);

// Create evolution class
using LevelSetEvolutionType = itk::LevelSetEvolution<EquationContainerType, LevelSetType>;
auto evolution = LevelSetEvolutionType::New();
evolution->SetEquationContainer(equationContainer);
evolution->SetStoppingCriterion(criterion);
evolution->SetLevelSetContainer(levelSetContainer);

using IterationUpdateCommandType = itk::LevelSetIterationUpdateCommand<LevelSetEvolutionType, VisualizationType>;
auto iterationUpdateCommand = IterationUpdateCommandType::New();
iterationUpdateCommand->SetFilterToUpdate(visualizer);
iterationUpdateCommand->SetUpdatePeriod(5);

evolution->AddObserver(itk::IterationEvent(), iterationUpdateCommand);

evolution->Update();

try
{
itk::WriteImage(levelSet->GetImage(), argv[3]);
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Visualize an Evolving Dense 2D Level Set as Elevation Map
=========================================================

.. index::
single: VTKVisualize2DLevelSetAsElevationMap
single: BinaryImageToLevelSetImageAdaptor
single: SinRegularizedHeavisideStepFunction
single: LevelSetDenseImage
Expand All @@ -13,13 +12,13 @@ Visualize an Evolving Dense 2D Level Set as Elevation Map
single: LevelSetEquationChanAndVeseExternalTerm
single: LevelSetEvolutionNumberOfIterationsStoppingCriterion
single: LevelSetEvolution
single: LevelSetIterationUpdateCommand


Synopsis
--------

Visualize an evolving dense level-set function 2D rendered as an elevation map.
Evolve a dense level-set function with the Chan and Vese region terms and write
the final function values as an image. Rendered as a height field, these values
form an elevation map whose zero level is the evolved contour.


Results
Expand All @@ -31,18 +30,6 @@ Results

Input image

.. figure:: levelsets.*
:scale: 100%
:alt: Evolving level-sets rendered as an elevation map

Evolving level-sets

.. only:: html

.. image:: levelsets.gif
:scale: 100%
:alt: Evolving level-sets animation


Code
----
Expand All @@ -57,4 +44,4 @@ C++
Classes demonstrated
--------------------

.. [breathelink:: itk::VTKVisualize2DLevelSetAsElevationMap]
.. breathelink:: itk::LevelSetEvolution
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ target_link_libraries(
PRIVATE
ITK::ITKImageIO
ITK::ITKCommonModule
ITK::ITKImageFeatureModule
ITK::ITKLevelSetsv4Module
)

install(
TARGETS
${PROJECT_NAME}
DESTINATION bin/ITKSphinxExamples/Bridge/VtkGlue
DESTINATION bin/ITKSphinxExamples/Segmentation/LevelSetsv4
COMPONENT Runtime
)

Expand All @@ -26,7 +27,7 @@ install(
Code.cxx
CMakeLists.txt
DESTINATION
share/ITKSphinxExamples/Code/Bridge/VtkGlue/VisualizeEvolvingDense2DLevelSetZeroSet
share/ITKSphinxExamples/Code/Segmentation/LevelSetsv4/VisualizeEvolvingDense2DLevelSetZeroSet
COMPONENT Code
)

Expand All @@ -35,7 +36,7 @@ add_test(
NAME VisualizeEvolvingDense2DLevelSetZeroSetTest
COMMAND
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}
${CMAKE_CURRENT_BINARY_DIR}/cells.png 100
${CMAKE_CURRENT_BINARY_DIR}/cells.png 100 Output.png
)
set_tests_properties(
VisualizeEvolvingDense2DLevelSetZeroSetTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "itkBinaryImageToLevelSetImageAdaptor.h"
#include "itkImageFileReader.h"
#include "itkLevelSetIterationUpdateCommand.h"
#include "itkLevelSetContainer.h"
#include "itkLevelSetEquationChanAndVeseInternalTerm.h"
#include "itkLevelSetEquationChanAndVeseExternalTerm.h"
Expand All @@ -27,18 +26,20 @@
#include "itkLevelSetEvolution.h"
#include "itkLevelSetEvolutionNumberOfIterationsStoppingCriterion.h"
#include "itkLevelSetDenseImage.h"
#include "itkVTKVisualizeImageLevelSetIsoValues.h"
#include "itkImageFileWriter.h"
#include "itkZeroCrossingImageFilter.h"
#include "itkSinRegularizedHeavisideStepFunction.h"

int
main(int argc, char * argv[])
{
if (argc != 3)
if (argc != 4)
{
std::cerr << "Missing Arguments" << std::endl;
std::cerr << argv[0] << std::endl;
std::cerr << "1- Input Image" << std::endl;
std::cerr << "2- Number of Iterations" << std::endl;
std::cerr << "3- Output Image" << std::endl;
return EXIT_FAILURE;
}

Expand Down Expand Up @@ -140,28 +141,31 @@ main(int argc, char * argv[])
auto criterion = StoppingCriterionType::New();
criterion->SetNumberOfIterations(numberOfIterations);

// Create the visualizer
using VisualizationType = itk::VTKVisualizeImageLevelSetIsoValues<InputImageType, LevelSetType>;
auto visualizer = VisualizationType::New();
visualizer->SetInputImage(input);
visualizer->SetLevelSet(levelSet);
visualizer->SetScreenCapture(true);

// Create evolution class
using LevelSetEvolutionType = itk::LevelSetEvolution<EquationContainerType, LevelSetType>;
auto evolution = LevelSetEvolutionType::New();
evolution->SetEquationContainer(equationContainer);
evolution->SetStoppingCriterion(criterion);
evolution->SetLevelSetContainer(levelSetContainer);

using IterationUpdateCommandType = itk::LevelSetIterationUpdateCommand<LevelSetEvolutionType, VisualizationType>;
auto iterationUpdateCommand = IterationUpdateCommandType::New();
iterationUpdateCommand->SetFilterToUpdate(visualizer);
iterationUpdateCommand->SetUpdatePeriod(5);
evolution->Update();

evolution->AddObserver(itk::IterationEvent(), iterationUpdateCommand);
using ZeroSetImageType = itk::Image<unsigned char, Dimension>;
using ZeroCrossingFilterType = itk::ZeroCrossingImageFilter<LevelSetImageType, ZeroSetImageType>;
auto zeroCrossing = ZeroCrossingFilterType::New();
zeroCrossing->SetInput(levelSet->GetImage());
zeroCrossing->SetForegroundValue(255);
zeroCrossing->SetBackgroundValue(0);

evolution->Update();
try
{
itk::WriteImage(zeroCrossing->GetOutput(), argv[3]);
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Visualize an Evolving Dense 2D Level-Set Zero-Set
=================================================

.. index::
single: VTKVisualizeImageLevelSetIsoValues
single: BinaryImageToLevelSetImageAdaptor
single: SinRegularizedHeavisideStepFunction
single: LevelSetDenseImage
Expand All @@ -13,13 +12,14 @@ Visualize an Evolving Dense 2D Level-Set Zero-Set
single: LevelSetEquationChanAndVeseExternalTerm
single: LevelSetEvolutionNumberOfIterationsStoppingCriterion
single: LevelSetEvolution
single: LevelSetIterationUpdateCommand

single: ZeroCrossingImageFilter

Synopsis
--------

Visualize the evolving zero-set of a dense level-set function 2D rendered.
Evolve a dense level-set function with the Chan and Vese region terms, extract
the zero set of the result with itk::ZeroCrossingImageFilter, and write the
contour as an image.


Results
Expand All @@ -31,18 +31,6 @@ Results

Input image

.. figure:: levelsets.*
:scale: 100%
:alt: Evolving level-sets

Evolving level-sets

.. only:: html

.. image:: levelsets.gif
:scale: 100%
:alt: Evolving level-sets animation


Code
----
Expand All @@ -57,4 +45,4 @@ C++
Classes demonstrated
--------------------

.. [breathelink:: itk::VTKVisualizeImageLevelSetIsoValues]
.. breathelink:: itk::LevelSetEvolution
2 changes: 2 additions & 0 deletions src/Segmentation/LevelSetsv4/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LevelSetsv4
.. toctree::
:maxdepth: 1

VisualizeEvolvingDense2DLevelSetAsElevationMap/Documentation.rst
VisualizeEvolvingDense2DLevelSetZeroSet/Documentation.rst
VisualizeStaticDense2DLevelSetAsElevationMap/Documentation.rst
VisualizeStaticDense2DLevelSetZeroSet/Documentation.rst
VisualizeStaticMalcolm2DLevelSetLayers/Documentation.rst
Expand Down
Loading