From 2597fccb39a29802bfd33832882e43b8b34b838f Mon Sep 17 00:00:00 2001 From: "Matt McCormick (thewtex)" Date: Thu, 13 May 2010 10:57:50 -0500 Subject: [PATCH 01/47] ENH: Move from itk-block-matching. --- .../Filtering/SplitComponents/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Modules/Filtering/SplitComponents/CMakeLists.txt diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt new file mode 100644 index 00000000000..f8149be8925 --- /dev/null +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8) +cmake_policy(VERSION 2.8) + +project(ITK_TENSOR_COMPONENTS) + +find_package(ITK REQUIRED) +include(${ITK_USE_FILE}) + +# where all the executables go +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ITK_TENSOR_COMPONENTS_BINARY_DIR}/bin) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Code) +add_subdirectory(Code) + +include(CTest) +if(BUILD_TESTING) + enable_testing() + add_subdirectory(Testing) +endif(BUILD_TESTING) From 446ee8806901eb38de0a729619764c1a232ea761 Mon Sep 17 00:00:00 2001 From: "Matt McCormick (thewtex)" Date: Mon, 11 Oct 2010 21:53:14 -0500 Subject: [PATCH 02/47] STYLE: Rename from TensorComponents to SplitComponents. People will not look for TensorComponents. --- Modules/Filtering/SplitComponents/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index f8149be8925..54dd17caf4a 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 2.8) cmake_policy(VERSION 2.8) -project(ITK_TENSOR_COMPONENTS) +project(ITK_SPLIT_COMPONENTS) find_package(ITK REQUIRED) include(${ITK_USE_FILE}) # where all the executables go -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ITK_TENSOR_COMPONENTS_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ITK_SPLIT_COMPONENTS_BINARY_DIR}/bin) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Code) add_subdirectory(Code) From d801ef6841fd5e4b135e9d54e9230137b0d7a98e Mon Sep 17 00:00:00 2001 From: "Matt McCormick (thewtex)" Date: Fri, 12 Nov 2010 06:20:46 -0600 Subject: [PATCH 03/47] ENH: Use IJMacros.txt. --- Modules/Filtering/SplitComponents/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index 54dd17caf4a..d3f5aacab3c 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -4,6 +4,11 @@ cmake_policy(VERSION 2.8) project(ITK_SPLIT_COMPONENTS) find_package(ITK REQUIRED) +include(IJMacros.txt) +set(REQUIRED_PACKAGES ITK3.20) +foreach(package ${REQUIRED_PACKAGES}) + loadpackage( ${package} ) +endforeach() include(${ITK_USE_FILE}) # where all the executables go From 63ea1a8518aca23e9f1571ddecc940562ce77c9f Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sat, 7 Jul 2012 00:10:36 -0400 Subject: [PATCH 04/47] COMP: Disable tests until can refactor to an ITK Module. --- Modules/Filtering/SplitComponents/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index d3f5aacab3c..dee048ad216 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -20,5 +20,6 @@ add_subdirectory(Code) include(CTest) if(BUILD_TESTING) enable_testing() - add_subdirectory(Testing) + # Should refactor to an ITK Module. + # add_subdirectory( Testing ) endif(BUILD_TESTING) From cfd82e7743eb3e579aec1603abeb9154a034ccfb Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sat, 14 Jul 2012 14:04:34 -0400 Subject: [PATCH 05/47] ENH: Make into an ITKv4 Module. Instructions at http://www.itk.org/Wiki/ITK/Release_4/Modularization --- .../Filtering/SplitComponents/CMakeLists.txt | 27 +---- .../include/itkSplitComponentsImageFilter.h | 93 ++++++++++++++++ .../include/itkSplitComponentsImageFilter.hxx | 75 +++++++++++++ .../SplitComponents/itk-module.cmake | 16 +++ ...ComponentsImageFilterTestBaseline0.mha.md5 | 1 + ...ComponentsImageFilterTestBaseline1.mha.md5 | 1 + .../SplitComponents/test/CMakeLists.txt | 19 ++++ .../itkSplitComponentsImageFilterTest.cxx | 103 ++++++++++++++++++ 8 files changed, 310 insertions(+), 25 deletions(-) create mode 100644 Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h create mode 100644 Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx create mode 100644 Modules/Filtering/SplitComponents/itk-module.cmake create mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 create mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 create mode 100644 Modules/Filtering/SplitComponents/test/CMakeLists.txt create mode 100644 Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index dee048ad216..5f15d05ff64 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,25 +1,2 @@ -cmake_minimum_required(VERSION 2.8) -cmake_policy(VERSION 2.8) - -project(ITK_SPLIT_COMPONENTS) - -find_package(ITK REQUIRED) -include(IJMacros.txt) -set(REQUIRED_PACKAGES ITK3.20) -foreach(package ${REQUIRED_PACKAGES}) - loadpackage( ${package} ) -endforeach() -include(${ITK_USE_FILE}) - -# where all the executables go -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ITK_SPLIT_COMPONENTS_BINARY_DIR}/bin) - -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Code) -add_subdirectory(Code) - -include(CTest) -if(BUILD_TESTING) - enable_testing() - # Should refactor to an ITK Module. - # add_subdirectory( Testing ) -endif(BUILD_TESTING) +project(ITKSplitComponents) +itk_module_impl() diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h new file mode 100644 index 00000000000..0db4569d48f --- /dev/null +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -0,0 +1,93 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef __itkSplitComponentsImageFilter_h +#define __itkSplitComponentsImageFilter_h + +#include "itkImageToImageFilter.h" + +namespace itk +{ + +/** \class SplitComponentsImageFilter + * + * \brief Extract components of an Image with multi-component pixels. + * + * This class extracts components of itk::Image of itk::Vector's + * itk::CovariantVector, itk::SymmetricSecondRankTensor, or other classes that + * have the same interface. The interface must implement ValueType operator[] ( + * unsigned int ). + * + * It puts an image on every output corresponding to each component. + * + * \ingroup ITKSplitComponents + * + * \sa VectorImageToImageAdaptor + * \sa Vector + * \sa CovariantVector + * \sa SymmetricSecondRankTensor + * \sa DiffusionTensor3D + * \sa NthElementImageAdaptor + */ +template +class ITK_EXPORT SplitComponentsImageFilter : public ImageToImageFilter +{ +public: + /** ImageDimension enumeration. */ + itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension); + /** Components enumeration. */ + itkStaticConstMacro(Components, unsigned int, TComponents); + + /** Image types. */ + typedef TInputImage InputImageType; + typedef TOutputImage OutputImageType; + typedef typename InputImageType::PixelType InputPixelType; + typedef typename OutputImageType::PixelType OutputPixelType; + typedef typename OutputImageType::RegionType OutputRegionType; + + /** Standard class typedefs. */ + typedef SplitComponentsImageFilter Self; + typedef ImageToImageFilter Superclass; + typedef SmartPointer Pointer; + typedef SmartPointer ConstPointer; + + /** Run-time type information (and related methods). */ + itkTypeMacro(SplitComponentsImageFilter, ImageToImageFilter); + + /** Provide ::New() */ + itkNewMacro(Self); + +protected: + SplitComponentsImageFilter(); + virtual ~SplitComponentsImageFilter() {} + + virtual void + ThreadedGenerateData(const OutputRegionType & outputRegion, ThreadIdType threadId); + +private: + SplitComponentsImageFilter(const Self &); // purposely not implemented + void + operator=(const Self &); // purposely not implemented +}; + +} // end namespace itk + +#ifndef ITK_MANUAL_INSTANTIATION +# include "itkSplitComponentsImageFilter.hxx" +#endif + +#endif diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx new file mode 100644 index 00000000000..cb5fae70af4 --- /dev/null +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -0,0 +1,75 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef __itkSplitComponentsImageFilter_hxx +#define __itkSplitComponentsImageFilter_hxx + +#include "itkSplitComponentsImageFilter.h" + +#include "itkImageRegionConstIterator.h" +#include "itkImageRegionIterator.h" + +namespace itk +{ + +template +SplitComponentsImageFilter::SplitComponentsImageFilter() +{ + this->SetNumberOfIndexedOutputs(Components); + + // ImageSource only does this for the first output. + for (unsigned int i = 1; i < Components; i++) + { + this->SetNthOutput(i, this->MakeOutput(i)); + } +} + +template +void +SplitComponentsImageFilter::ThreadedGenerateData( + const OutputRegionType & outputRegion, + ThreadIdType itkNotUsed(threadId)) +{ + typename InputImageType::ConstPointer input = this->GetInput(); + + ProcessObject::DataObjectPointerArray outputs = this->GetOutputs(); + + typedef ImageRegionIterator OutputIteratorType; + ImageRegionConstIterator inIt(input, outputRegion); + std::vector outIts; + unsigned int i; + for (i = 0; i < Components; i++) + { + OutputIteratorType outIt(dynamic_cast(outputs[i].GetPointer()), outputRegion); + outIt.GoToBegin(); + outIts.push_back(outIt); + } + InputPixelType inputPixel; + for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) + { + inputPixel = inIt.Get(); + for (i = 0; i < Components; i++) + { + outIts[i].Set(static_cast(inputPixel[i])); + ++(outIts[i]); + } + } +} + +} // end namespace itk + +#endif diff --git a/Modules/Filtering/SplitComponents/itk-module.cmake b/Modules/Filtering/SplitComponents/itk-module.cmake new file mode 100644 index 00000000000..e694da70aea --- /dev/null +++ b/Modules/Filtering/SplitComponents/itk-module.cmake @@ -0,0 +1,16 @@ +set( + DOCUMENTATION + "This module contains filter called +itk::SplitComponentsImageFilter. This filter generates component images from an +itk::Image of, for example, itk::Vector, itk::CovariantVector, or +itk::SymmetricSecondRankTensor." +) + +itk_module( + ITKSplitComponents + DEPENDS + ITKCommon + TEST_DEPENDS + ITKTestKernel + DESCRIPTION "${DOCUMENTATION}" +) diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 new file mode 100644 index 00000000000..29653c0ffb0 --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 @@ -0,0 +1 @@ +a3519cb25bb2bfeda9d976da2f9707cd diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 new file mode 100644 index 00000000000..aa1a188ae55 --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 @@ -0,0 +1 @@ +b53699740d1fafd85bd66a9df0c23b5a diff --git a/Modules/Filtering/SplitComponents/test/CMakeLists.txt b/Modules/Filtering/SplitComponents/test/CMakeLists.txt new file mode 100644 index 00000000000..784e49d32b2 --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/CMakeLists.txt @@ -0,0 +1,19 @@ +itk_module_test() +set(ITKSplitComponentsTests itkSplitComponentsImageFilterTest.cxx) +createtestdriver( ITKSplitComponents "${ITKSplitComponents-Test_LIBRARIES}" "${ITKSplitComponentsTests}") + +set(TEMP ${ITK_TEST_OUTPUT_DIR}) + +itk_add_test( + NAME itkSplitComponentsImageFilterTest + COMMAND + ITKSplitComponentsTestDriver + --compare + DATA{Baseline/itkSplitComponentsImageFilterTestBaseline0.mha} + itkSplitComponentsImageFilterTestOutput0.mha + --compare + DATA{Baseline/itkSplitComponentsImageFilterTestBaseline1.mha} + itkSplitComponentsImageFilterTestOutput1.mha + itkSplitComponentsImageFilterTest + itkSplitComponentsImageFilterTestOutput +) diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx new file mode 100644 index 00000000000..10bca829abd --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -0,0 +1,103 @@ +/*========================================================================= + * + * Copyright Insight Software Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#include "itkImage.h" +#include "itkImageFileWriter.h" +#include "itkImageRegionIteratorWithIndex.h" +#include "itkVector.h" + +#include + +#include "itkSplitComponentsImageFilter.h" + +int +itkSplitComponentsImageFilterTest(int argc, char * argv[]) +{ + if (argc < 2) + { + std::cerr << "Usage: " << argv[0]; + std::cerr << " outputImagePrefix "; + std::cerr << std::endl; + return EXIT_FAILURE; + } + + const unsigned int Dimension = 2; + typedef signed short PixelType; + typedef itk::Image OutputImageType; + typedef itk::Vector VectorType; + typedef itk::Image InputImageType; + + // Size in every dimension of the output image. + const unsigned int sizes = 100; + + InputImageType::Pointer input = InputImageType::New(); + + typedef InputImageType::RegionType RegionType; + RegionType region; + RegionType::IndexType index; + index.Fill(0); + region.SetIndex(index); + RegionType::SizeType size; + for (unsigned int i = 0; i < Dimension; i++) + { + size[i] = sizes; + } + region.SetSize(size); + + input->SetRegions(region); + input->Allocate(); + + itk::ImageRegionIteratorWithIndex it(input, region); + VectorType vector; + for (it.GoToBegin(); !it.IsAtEnd(); ++it) + { + index = it.GetIndex(); + vector[0] = index[0]; + vector[1] = index[1]; + it.Set(vector); + } + + typedef itk::SplitComponentsImageFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + filter->SetInput(input); + + typedef itk::ImageFileWriter WriterType; + WriterType::Pointer writer = WriterType::New(); + + std::ostringstream ostr; + try + { + ostr << argv[1] << 0 << ".mha"; + writer->SetFileName(ostr.str()); + writer->SetInput(filter->GetOutput()); + writer->Update(); + + ostr.str(""); + ostr << argv[1] << 1 << ".mha"; + writer->SetFileName(ostr.str()); + writer->SetInput(filter->GetOutput(1)); + writer->Update(); + } + catch (itk::ExceptionObject & ex) + { + std::cerr << "Exception caught!" << std::endl; + std::cerr << ex << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} From 02d9f11a45817fb10c63bd5da0c0a84b854b0f92 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 15 Jul 2012 13:56:55 -0400 Subject: [PATCH 06/47] ENH: Add ComponentsMask parameter. This allows one to specify which output components are allocated and populated. Based off feedback from Cory Quammen in review comments in the Insight Journal. --- .../include/itkSplitComponentsImageFilter.h | 15 +++++ .../include/itkSplitComponentsImageFilter.hxx | 55 +++++++++++++++---- .../itkSplitComponentsImageFilterTest.cxx | 28 ++++++++++ 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 0db4569d48f..6ed8678805c 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -18,6 +18,7 @@ #ifndef __itkSplitComponentsImageFilter_h #define __itkSplitComponentsImageFilter_h +#include "itkFixedArray.h" #include "itkImageToImageFilter.h" namespace itk @@ -65,16 +66,28 @@ class ITK_EXPORT SplitComponentsImageFilter : public ImageToImageFilter Pointer; typedef SmartPointer ConstPointer; + typedef FixedArray ComponentsMaskType; + /** Run-time type information (and related methods). */ itkTypeMacro(SplitComponentsImageFilter, ImageToImageFilter); /** Provide ::New() */ itkNewMacro(Self); + /** Set/Get the components mask. The mask is as long as the number of + * components, and only values in the mask that evaluate are true will be + * populated in the output. The default is all true. */ + itkSetMacro(ComponentsMask, ComponentsMaskType); + itkGetConstReferenceMacro(ComponentsMask, ComponentsMaskType); + protected: SplitComponentsImageFilter(); virtual ~SplitComponentsImageFilter() {} + /** Do not allocate outputs that we will not populate. */ + virtual void + AllocateOutputs(); + virtual void ThreadedGenerateData(const OutputRegionType & outputRegion, ThreadIdType threadId); @@ -82,6 +95,8 @@ class ITK_EXPORT SplitComponentsImageFilter : public ImageToImageFilter SplitComponentsImageFilter::SplitComponentsImageFilter() { + this->m_ComponentsMask.Fill(true); + this->SetNumberOfIndexedOutputs(Components); // ImageSource only does this for the first output. @@ -38,6 +40,34 @@ SplitComponentsImageFilter::SplitCompone } } + +template +void +SplitComponentsImageFilter::AllocateOutputs() +{ + typedef ImageBase ImageBaseType; + typename ImageBaseType::Pointer outputPtr; + + // Allocate the output memory as with ImageSource + unsigned int ii = 0; + for (OutputDataObjectIterator it(this); !it.IsAtEnd(); ++it, ++ii) + { + // Check whether the output is an image of the appropriate + // dimension (use ProcessObject's version of the GetInput() + // method since it returns the input as a pointer to a + // DataObject as opposed to the subclass version which + // static_casts the input to an TInputImage). + outputPtr = dynamic_cast(it.GetOutput()); + + if (outputPtr && this->m_ComponentsMask[ii]) + { + outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); + outputPtr->Allocate(); + } + } +} + + template void SplitComponentsImageFilter::ThreadedGenerateData( @@ -45,27 +75,32 @@ SplitComponentsImageFilter::ThreadedGene ThreadIdType itkNotUsed(threadId)) { typename InputImageType::ConstPointer input = this->GetInput(); - ProcessObject::DataObjectPointerArray outputs = this->GetOutputs(); + const ComponentsMaskType componentsMask = this->m_ComponentsMask; typedef ImageRegionIterator OutputIteratorType; ImageRegionConstIterator inIt(input, outputRegion); - std::vector outIts; - unsigned int i; - for (i = 0; i < Components; i++) + std::vector outIts(Components); + for (unsigned int ii = 0; ii < Components; ++ii) { - OutputIteratorType outIt(dynamic_cast(outputs[i].GetPointer()), outputRegion); - outIt.GoToBegin(); - outIts.push_back(outIt); + if (componentsMask[ii]) + { + OutputIteratorType outIt(dynamic_cast(outputs[ii].GetPointer()), outputRegion); + outIt.GoToBegin(); + outIts[ii] = outIt; + } } InputPixelType inputPixel; for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) { inputPixel = inIt.Get(); - for (i = 0; i < Components; i++) + for (unsigned int ii = 0; ii < Components; ++ii) { - outIts[i].Set(static_cast(inputPixel[i])); - ++(outIts[i]); + if (componentsMask[ii]) + { + outIts[ii].Set(static_cast(inputPixel[ii])); + ++(outIts[ii]); + } } } } diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx index 10bca829abd..5401f03a495 100644 --- a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -99,5 +99,33 @@ itkSplitComponentsImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } + typedef FilterType::ComponentsMaskType ComponentsMaskType; + ComponentsMaskType componentsMask(false); + componentsMask[1] = true; + const ComponentsMaskType oldComponents = filter->GetComponentsMask(); + if (oldComponents[0] != true) + { + std::cerr << "Did not get the expected default ComponentsMask." << std::endl; + return EXIT_FAILURE; + } + filter->SetComponentsMask(componentsMask); + const ComponentsMaskType newComponents = filter->GetComponentsMask(); + if (newComponents[0] != false) + { + std::cerr << "Did not get the expected modified ComponentsMask." << std::endl; + return EXIT_FAILURE; + } + + try + { + filter->Update(); + } + catch (itk::ExceptionObject & ex) + { + std::cerr << "Exception caught!" << std::endl; + std::cerr << ex << std::endl; + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } From cc253d08f51a3520cee1ef66978cfd13bd4c7748 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 24 Jan 2014 02:11:52 -0500 Subject: [PATCH 07/47] ENH: Rename to Remote Module conventions. --- Modules/Filtering/SplitComponents/CMakeLists.txt | 2 +- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- Modules/Filtering/SplitComponents/itk-module.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index 5f15d05ff64..147773cd04a 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,2 +1,2 @@ -project(ITKSplitComponents) +project(SplitComponents) itk_module_impl() diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 6ed8678805c..01022377c64 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -35,7 +35,7 @@ namespace itk * * It puts an image on every output corresponding to each component. * - * \ingroup ITKSplitComponents + * \ingroup SplitComponents * * \sa VectorImageToImageAdaptor * \sa Vector diff --git a/Modules/Filtering/SplitComponents/itk-module.cmake b/Modules/Filtering/SplitComponents/itk-module.cmake index e694da70aea..430d4de7437 100644 --- a/Modules/Filtering/SplitComponents/itk-module.cmake +++ b/Modules/Filtering/SplitComponents/itk-module.cmake @@ -7,7 +7,7 @@ itk::SymmetricSecondRankTensor." ) itk_module( - ITKSplitComponents + SplitComponents DEPENDS ITKCommon TEST_DEPENDS From 551a79f48b38a4b1d5dde326a9b121023350e326 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Thu, 6 Feb 2014 16:15:50 -0500 Subject: [PATCH 08/47] BUG: Add EXCLUDE_FROM_DEFAULT. --- Modules/Filtering/SplitComponents/itk-module.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Filtering/SplitComponents/itk-module.cmake b/Modules/Filtering/SplitComponents/itk-module.cmake index 430d4de7437..a5dceded921 100644 --- a/Modules/Filtering/SplitComponents/itk-module.cmake +++ b/Modules/Filtering/SplitComponents/itk-module.cmake @@ -13,4 +13,5 @@ itk_module( TEST_DEPENDS ITKTestKernel DESCRIPTION "${DOCUMENTATION}" + EXCLUDE_FROM_DEFAULT ) From 7380489e1004f3aa5391615a2c13cd75aaecd16a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 17 Feb 2014 11:35:50 -0500 Subject: [PATCH 09/47] STYLE: Remove unused ITK_EXPORT. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 01022377c64..17173bdbc0d 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -45,7 +45,7 @@ namespace itk * \sa NthElementImageAdaptor */ template -class ITK_EXPORT SplitComponentsImageFilter : public ImageToImageFilter +class SplitComponentsImageFilter : public ImageToImageFilter { public: /** ImageDimension enumeration. */ From 1dbbba1d35bded08be8ec75f9b501fd4b18fd96a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 17 Feb 2014 11:40:51 -0500 Subject: [PATCH 10/47] STYLE: More standard description of itkNewMacro. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 17173bdbc0d..d4b4987e20b 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -71,7 +71,7 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Mon, 23 Mar 2015 19:18:10 -0400 Subject: [PATCH 11/47] STYLE: Remove __ from header guards. These are reserved for compiler pre-processor definitions. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 4 ++-- .../SplitComponents/include/itkSplitComponentsImageFilter.hxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index d4b4987e20b..7f47c8453ef 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -15,8 +15,8 @@ * limitations under the License. * *=========================================================================*/ -#ifndef __itkSplitComponentsImageFilter_h -#define __itkSplitComponentsImageFilter_h +#ifndef itkSplitComponentsImageFilter_h +#define itkSplitComponentsImageFilter_h #include "itkFixedArray.h" #include "itkImageToImageFilter.h" diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index 095f9fbfaaf..8cd2d512ea1 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -15,8 +15,8 @@ * limitations under the License. * *=========================================================================*/ -#ifndef __itkSplitComponentsImageFilter_hxx -#define __itkSplitComponentsImageFilter_hxx +#ifndef itkSplitComponentsImageFilter_hxx +#define itkSplitComponentsImageFilter_hxx #include "itkSplitComponentsImageFilter.h" From 5ee83881ffbf16280b0fba66bcc4931d2d42516e Mon Sep 17 00:00:00 2001 From: Zach Williamson Date: Thu, 30 Jun 2016 13:49:53 -0500 Subject: [PATCH 12/47] STYLE: Use Macro for Function Deletion --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 7f47c8453ef..100291b0e54 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -92,9 +92,7 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Sat, 16 Dec 2017 14:50:19 -0600 Subject: [PATCH 13/47] ENH: Initial ITKv5 conversions. Provide initial conversion of features to ITKv5. --- .../include/itkSplitComponentsImageFilter.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 100291b0e54..593b719f5eb 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -82,14 +82,14 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Sat, 16 Dec 2017 19:17:17 -0600 Subject: [PATCH 14/47] ENH: ITKv5 override consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide remove virtual and override Use clang-tidy to add ITK_OVERRIDE, and to remove redundant virtual on functions. cd ../ITK; clang-tidy -p ITK-clangtidy $find Modules/[A-J]* -name *.cxx |fgrep -v ThirdParty) -checks=-*,modernize-use-override -header-filter=.* -fix clang-tidy -p ITK-clangtidy $(find Modules/[K-Z]* -name *.cxx |fgrep -v ThirdParty) -checks=-*,modernize-use-override -header-filter=.* -fix https://stackoverflow.com/questions/39932391/virtual-override-or-both-c When you override a function you don't technically need to write either virtual or override. The original base class declaration needs the keyword virtual to mark it as virtual. In the derived class the function is virtual by way of having the ¹same type as the base class function. However, an override can help avoid bugs by producing a compilation error when the intended override isn't technically an override. E.g. that the function type isn't exactly like the base class function. Or that a maintenance of the base class changes that function's type, e.g. adding a defaulted argument. In the same way, a virtual keyword in the derived class can make such a bug more subtle, by ensuring that the function is still is virtual in further derived classes. So the general advice is, virtual for the base class function declaration. This is technically necessary. Use override (only) for a derived class' override. This helps with maintenance. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 593b719f5eb..89b8d71b41a 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -82,14 +82,14 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Sat, 16 Dec 2017 19:36:27 -0600 Subject: [PATCH 15/47] COMP: Use C++11 override directly git grep -l "ITK_OVERRIDE" | fgrep -v itk_compiler_detection.h | fgrep -v CMakeLists.txt |fgrep -v .cmake | xargs sed -i '' -e "s/ITK_OVERRIDE/override/g" --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 89b8d71b41a..593b719f5eb 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -82,14 +82,14 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Mon, 12 Feb 2018 21:05:31 -0600 Subject: [PATCH 16/47] STYLE: Replace itkStaticConstMacro with static constexpr Use static constexpr directly now that C++11 conformance is required by all compilers. :%s/itkStaticConstMacro *( *\([^,]*\),[ \_s]*\([^,]*\),\_s*\([^)]*\)) */static constexpr \2 \1 = \3/ge --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 593b719f5eb..a5dd6c250ad 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -49,9 +49,9 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Mon, 12 Feb 2018 23:31:19 -0600 Subject: [PATCH 17/47] STYLE: Prefer C++11 type alias over typedef == http://en.cppreference.com/w/cpp/language/type_alias == Type alias is a name that refers to a previously defined type (similar to typedef). A type alias declaration introduces a name which can be used as a synonym for the type denoted by type-id. It does not introduce a new type and it cannot change the meaning of an existing type name. There is no difference between a type alias declaration and typedef declaration. This declaration may appear in block scope, class scope, or namespace scope. == https://www.quora.com/Is-using-typedef-in-C++-considered-a-bad-practice == While typedef is still available for backward compatibility, the new Type Alias syntax 'using Alias = ExistingLongName;' is more consistent with the flow of C++ than the old typedef syntax 'typedef ExistingLongName Alias;', and it also works for templates (Type alias, alias template (since C++11)), so leftover 'typedef' aliases will differ in style from any alias templates. --- .../include/itkSplitComponentsImageFilter.h | 26 ++++++++--------- .../include/itkSplitComponentsImageFilter.hxx | 10 +++---- .../itkSplitComponentsImageFilterTest.cxx | 28 +++++++++---------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index a5dd6c250ad..6cb1672682d 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -54,19 +54,19 @@ class SplitComponentsImageFilter : public ImageToImageFilter Superclass; - typedef SmartPointer Pointer; - typedef SmartPointer ConstPointer; - - typedef FixedArray ComponentsMaskType; + using InputImageType = TInputImage; + using OutputImageType = TOutputImage; + using InputPixelType = typename InputImageType::PixelType; + using OutputPixelType = typename OutputImageType::PixelType; + using OutputRegionType = typename OutputImageType::RegionType; + + /** Standard class type alias. */ + using Self = SplitComponentsImageFilter; + using Superclass = ImageToImageFilter; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; + + using ComponentsMaskType = FixedArray; /** Run-time type information (and related methods). */ itkTypeMacro(SplitComponentsImageFilter, ImageToImageFilter); diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index 8cd2d512ea1..c7f7f1a0baf 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -45,8 +45,8 @@ template void SplitComponentsImageFilter::AllocateOutputs() { - typedef ImageBase ImageBaseType; - typename ImageBaseType::Pointer outputPtr; + using ImageBaseType = ImageBase; + typename ImageBaseType::Pointer outputPtr; // Allocate the output memory as with ImageSource unsigned int ii = 0; @@ -78,9 +78,9 @@ SplitComponentsImageFilter::ThreadedGene ProcessObject::DataObjectPointerArray outputs = this->GetOutputs(); const ComponentsMaskType componentsMask = this->m_ComponentsMask; - typedef ImageRegionIterator OutputIteratorType; - ImageRegionConstIterator inIt(input, outputRegion); - std::vector outIts(Components); + using OutputIteratorType = ImageRegionIterator; + ImageRegionConstIterator inIt(input, outputRegion); + std::vector outIts(Components); for (unsigned int ii = 0; ii < Components; ++ii) { if (componentsMask[ii]) diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx index 5401f03a495..22a024a3dc5 100644 --- a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -35,20 +35,20 @@ itkSplitComponentsImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - const unsigned int Dimension = 2; - typedef signed short PixelType; - typedef itk::Image OutputImageType; - typedef itk::Vector VectorType; - typedef itk::Image InputImageType; + const unsigned int Dimension = 2; + using PixelType = signed short; + using OutputImageType = itk::Image; + using VectorType = itk::Vector; + using InputImageType = itk::Image; // Size in every dimension of the output image. const unsigned int sizes = 100; InputImageType::Pointer input = InputImageType::New(); - typedef InputImageType::RegionType RegionType; - RegionType region; - RegionType::IndexType index; + using RegionType = InputImageType::RegionType; + RegionType region; + RegionType::IndexType index; index.Fill(0); region.SetIndex(index); RegionType::SizeType size; @@ -71,12 +71,12 @@ itkSplitComponentsImageFilterTest(int argc, char * argv[]) it.Set(vector); } - typedef itk::SplitComponentsImageFilter FilterType; - FilterType::Pointer filter = FilterType::New(); + using FilterType = itk::SplitComponentsImageFilter; + FilterType::Pointer filter = FilterType::New(); filter->SetInput(input); - typedef itk::ImageFileWriter WriterType; - WriterType::Pointer writer = WriterType::New(); + using WriterType = itk::ImageFileWriter; + WriterType::Pointer writer = WriterType::New(); std::ostringstream ostr; try @@ -99,8 +99,8 @@ itkSplitComponentsImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - typedef FilterType::ComponentsMaskType ComponentsMaskType; - ComponentsMaskType componentsMask(false); + using ComponentsMaskType = FilterType::ComponentsMaskType; + ComponentsMaskType componentsMask(false); componentsMask[1] = true; const ComponentsMaskType oldComponents = filter->GetComponentsMask(); if (oldComponents[0] != true) From ef447d64e4864d040f5f2fcc06d019e593ab1cc8 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Tue, 13 Feb 2018 08:25:44 -0600 Subject: [PATCH 18/47] STYLE: Prefer constexpr for const numeric literals Use constexpr for constant numeric literals. --- .../test/itkSplitComponentsImageFilterTest.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx index 22a024a3dc5..9fc29efa991 100644 --- a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -35,14 +35,14 @@ itkSplitComponentsImageFilterTest(int argc, char * argv[]) return EXIT_FAILURE; } - const unsigned int Dimension = 2; + constexpr unsigned int Dimension = 2; using PixelType = signed short; using OutputImageType = itk::Image; using VectorType = itk::Vector; using InputImageType = itk::Image; // Size in every dimension of the output image. - const unsigned int sizes = 100; + constexpr unsigned int sizes = 100; InputImageType::Pointer input = InputImageType::New(); From 1fb53fdcd9b4c0f738dee1430e85df667d071799 Mon Sep 17 00:00:00 2001 From: Jon Haitz Legarreta Date: Sat, 14 Apr 2018 19:38:52 +0200 Subject: [PATCH 19/47] COMP: Move ITK_DISALLOW_COPY_AND_ASSIGN calls to public section. Move `ITK_DISALLOW_COPY_AND_ASSIGN` calls to public section following the discussion in https://discourse.itk.org/t/noncopyable If legacy (pre-macro) copy and assing methods existed, subsitute them for the `ITK_DISALLOW_COPY_AND_ASSIGN` macro. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 6cb1672682d..d24de0fad4f 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -48,6 +48,8 @@ template { public: + ITK_DISALLOW_COPY_AND_ASSIGN(SplitComponentsImageFilter); + /** ImageDimension enumeration. */ static constexpr unsigned int ImageDimension = TInputImage::ImageDimension; /** Components enumeration. */ @@ -92,8 +94,6 @@ class SplitComponentsImageFilter : public ImageToImageFilter Date: Wed, 23 May 2018 20:06:36 +0200 Subject: [PATCH 20/47] BUG: Fix test errors steming from the new multi-threading mechanism. Fix errors steming from the use of the new `itk::PoolMultiThreader` class for multi-threading. The errors stemmed when this gerrit topic got merged: http://review.source.kitware.com/#/c/23175/ And were later related to the following gerrit-topic: http://review.source.kitware.com/#/c/23434/ The solution adopted in this patch set was based on the proposal in: http://review.source.kitware.com/#/c/23439/ --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- .../include/itkSplitComponentsImageFilter.hxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index d24de0fad4f..e65c0072375 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -91,7 +91,7 @@ class SplitComponentsImageFilter : public ImageToImageFilter SplitComponentsImageFilter::SplitComponentsImageFilter() + : m_DynamicMultiThreading(true) { this->m_ComponentsMask.Fill(true); @@ -70,9 +71,8 @@ SplitComponentsImageFilter::AllocateOutp template void -SplitComponentsImageFilter::ThreadedGenerateData( - const OutputRegionType & outputRegion, - ThreadIdType itkNotUsed(threadId)) +SplitComponentsImageFilter::DynamicThreadedGenerateData( + const OutputRegionType & outputRegion) { typename InputImageType::ConstPointer input = this->GetInput(); ProcessObject::DataObjectPointerArray outputs = this->GetOutputs(); From fa23321c89a01c7c27200bb43fc80923e18fd1ad Mon Sep 17 00:00:00 2001 From: Jon Haitz Legarreta Date: Tue, 29 May 2018 08:50:44 +0200 Subject: [PATCH 21/47] ENH: Prefer boolean macro call to initialize dynamic multi-threading ivar. Prefer the boolean macro function call to initialize the dynamic multi-threading ivar for the reasons stated here: http://review.source.kitware.com/#/c/23434/ --- .../SplitComponents/include/itkSplitComponentsImageFilter.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index ceac827aebd..280e7167bf6 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -28,7 +28,6 @@ namespace itk template SplitComponentsImageFilter::SplitComponentsImageFilter() - : m_DynamicMultiThreading(true) { this->m_ComponentsMask.Fill(true); @@ -39,6 +38,8 @@ SplitComponentsImageFilter::SplitCompone { this->SetNthOutput(i, this->MakeOutput(i)); } + + this->DynamicMultiThreadingOn(); } From 5c23fb7b5a877651fe0b69cc3b0e2b33e0f1b79b Mon Sep 17 00:00:00 2001 From: Jon Haitz Legarreta Date: Thu, 31 May 2018 16:20:56 +0200 Subject: [PATCH 22/47] BUG: Allow for building outside ITK. Re-work the `CMakeLists.txt` file so that the module can be built outside ITK, following: https://github.com/InsightSoftwareConsortium/ITKModuleTemplate/commit/b4d185d6cdda423f5c344a3ad3d40341db06d401 --- Modules/Filtering/SplitComponents/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index 147773cd04a..8131f296e63 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,2 +1,6 @@ +cmake_minimum_required(VERSION 3.10.2) project(SplitComponents) + +set(SplitComponents_LIBRARIES SplitComponents) + itk_module_impl() From 5897d140f708814a89e3d2b0caadfd763697abb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Fri, 1 Jun 2018 09:43:49 -0400 Subject: [PATCH 23/47] BUG: fix fatal error LNK1181: cannot open input file 'SplitComponents.lib' --- Modules/Filtering/SplitComponents/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index 8131f296e63..e6cb378d823 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10.2) project(SplitComponents) -set(SplitComponents_LIBRARIES SplitComponents) +# set(SplitComponents_LIBRARIES SplitComponents) # header-only module, so no libraries itk_module_impl() From cc67e97370df1699b803297911a350cb1b7afd2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Thu, 7 Jun 2018 16:26:32 +0200 Subject: [PATCH 24/47] ENH: Add CI configuration files. Add CircleCI configuration files and badges. --- .../Filtering/SplitComponents/wrapping/CMakeLists.txt | 3 +++ .../wrapping/itkSplitComponentsImageFilter.wrap | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Modules/Filtering/SplitComponents/wrapping/CMakeLists.txt create mode 100644 Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap diff --git a/Modules/Filtering/SplitComponents/wrapping/CMakeLists.txt b/Modules/Filtering/SplitComponents/wrapping/CMakeLists.txt new file mode 100644 index 00000000000..7703111ef33 --- /dev/null +++ b/Modules/Filtering/SplitComponents/wrapping/CMakeLists.txt @@ -0,0 +1,3 @@ +itk_wrap_module(SplitComponents) +itk_auto_load_submodules() +itk_end_wrap_module() diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap new file mode 100644 index 00000000000..ae5a78c10e8 --- /dev/null +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -0,0 +1,11 @@ +itk_wrap_class("itk::SplitComponentsImageFilter" POINTER) +foreach(d ${ITK_WRAP_IMAGE_DIMS}) + set(vector_dim ${d}) # Wrap only vector dimensions which are the same as image dimensions + foreach(p D) + itk_wrap_template( + "${ITKM_IV${p}${vector_dim}${d}}${ITKM_${p}}${ITKM_${p}}" + "${ITKT_IV${p}${vector_dim}${d}}, ${ITKT_${p}}, ${ITKT_${p}}" + ) + endforeach() +endforeach() +itk_end_wrap_class() From 0cd1eb230daed2b61736c5235ddca5612869428d Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Sun, 15 Jul 2018 21:19:29 -0400 Subject: [PATCH 25/47] COMP: Fix Python wrapping --- .../wrapping/itkSplitComponentsImageFilter.wrap | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap index ae5a78c10e8..95a63073677 100644 --- a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -1,10 +1,9 @@ itk_wrap_class("itk::SplitComponentsImageFilter" POINTER) foreach(d ${ITK_WRAP_IMAGE_DIMS}) - set(vector_dim ${d}) # Wrap only vector dimensions which are the same as image dimensions - foreach(p D) + foreach(t ${WRAP_ITK_REAL}) itk_wrap_template( - "${ITKM_IV${p}${vector_dim}${d}}${ITKM_${p}}${ITKM_${p}}" - "${ITKT_IV${p}${vector_dim}${d}}, ${ITKT_${p}}, ${ITKT_${p}}" + "${ITKM_IV${t}${d}${d}}${ITKM_I${t}${d}}" + "${ITKT_IV${t}${d}${d}}, ${ITKT_I${t}${d}}" ) endforeach() endforeach() From 6480ced677ac3f17fae44ea4af71053f82b7047c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 18 Jul 2018 12:33:51 -0400 Subject: [PATCH 26/47] BUG: Add missing ITK_TEMPLATE_EXPORT --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index e65c0072375..fb7cd3e3e12 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -45,7 +45,7 @@ namespace itk * \sa NthElementImageAdaptor */ template -class SplitComponentsImageFilter : public ImageToImageFilter +class ITK_TEMPLATE_EXPORT SplitComponentsImageFilter : public ImageToImageFilter { public: ITK_DISALLOW_COPY_AND_ASSIGN(SplitComponentsImageFilter); From 436ea60288a5d61698d72d2878e4d325d21cad6a Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Mon, 1 Oct 2018 11:05:37 -0400 Subject: [PATCH 27/47] DOC: Add LICENSE file Closes #19 --- Modules/Filtering/SplitComponents/LICENSE | 202 ++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 Modules/Filtering/SplitComponents/LICENSE diff --git a/Modules/Filtering/SplitComponents/LICENSE b/Modules/Filtering/SplitComponents/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/Modules/Filtering/SplitComponents/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 5a9793f60410e70c49acb6edd31029287a24d1c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Tue, 9 Oct 2018 19:22:40 -0400 Subject: [PATCH 28/47] STYLE: Use "typename" for template parameters. As discussed in: http://review.source.kitware.com/#/c/12655/ the use of the template keyword "class" was substituted by "typename" in the toolkit for the reasons stated in that topic. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- .../include/itkSplitComponentsImageFilter.hxx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index fb7cd3e3e12..5d09db5863b 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -44,7 +44,7 @@ namespace itk * \sa DiffusionTensor3D * \sa NthElementImageAdaptor */ -template +template class ITK_TEMPLATE_EXPORT SplitComponentsImageFilter : public ImageToImageFilter { public: diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index 280e7167bf6..fb0354ffe02 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -26,7 +26,7 @@ namespace itk { -template +template SplitComponentsImageFilter::SplitComponentsImageFilter() { this->m_ComponentsMask.Fill(true); @@ -43,7 +43,7 @@ SplitComponentsImageFilter::SplitCompone } -template +template void SplitComponentsImageFilter::AllocateOutputs() { @@ -70,7 +70,7 @@ SplitComponentsImageFilter::AllocateOutp } -template +template void SplitComponentsImageFilter::DynamicThreadedGenerateData( const OutputRegionType & outputRegion) From 4443fbb9be26e50db8c73f58cb298c59960b46e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Fri, 21 Dec 2018 20:48:34 -0500 Subject: [PATCH 29/47] DOC: Re-use `README.rst` info in `itk-module.cmake`. Re-use `README.rst` info in `itk-module.cmake`. Helps avoiding duplications/diverging versions of the documentation. --- .../Filtering/SplitComponents/itk-module.cmake | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Modules/Filtering/SplitComponents/itk-module.cmake b/Modules/Filtering/SplitComponents/itk-module.cmake index a5dceded921..c8820178073 100644 --- a/Modules/Filtering/SplitComponents/itk-module.cmake +++ b/Modules/Filtering/SplitComponents/itk-module.cmake @@ -1,11 +1,14 @@ -set( - DOCUMENTATION - "This module contains filter called -itk::SplitComponentsImageFilter. This filter generates component images from an -itk::Image of, for example, itk::Vector, itk::CovariantVector, or -itk::SymmetricSecondRankTensor." -) +# the top-level README is used for describing this module, just +# re-used it for documentation here +get_filename_component(MY_CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(READ "${MY_CURRENT_DIR}/README.md" DOCUMENTATION) + +# itk_module() defines the module dependencies in SplitComponents +# The testing module in SplitComponents depends on ITKTestKernel +# By convention those modules outside of ITK are not prefixed with +# ITK. +# define the dependencies of the include module and the tests itk_module( SplitComponents DEPENDS From f8cfa38f188bb8e39343c0eab6e1bb2aad7b8bd4 Mon Sep 17 00:00:00 2001 From: Francois Budin Date: Fri, 29 Mar 2019 10:09:32 -0400 Subject: [PATCH 30/47] ENH: Add RGB and RGBA support in Python --- .../itkSplitComponentsImageFilter.wrap | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap index 95a63073677..1244b3c1c16 100644 --- a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -1,10 +1,39 @@ itk_wrap_class("itk::SplitComponentsImageFilter" POINTER) +# We can only wrap types that have been wrapped for +# ImageToImageFilter (parent class). +unique(types "${WRAP_ITK_REAL};UC") foreach(d ${ITK_WRAP_IMAGE_DIMS}) - foreach(t ${WRAP_ITK_REAL}) - itk_wrap_template( + foreach(t ${types}) + if(DEFINED ITKT_IV${t}${d}${d}) + itk_wrap_template( "${ITKM_IV${t}${d}${d}}${ITKM_I${t}${d}}" "${ITKT_IV${t}${d}${d}}, ${ITKT_I${t}${d}}" - ) + ) + endif() + endforeach() +endforeach() +foreach(d ${ITK_WRAP_IMAGE_DIMS}) + unique(types "${WRAP_ITK_SCALAR};UC;D;US;UI;UL;SC;SS;SI;SL;F") + # Define filter for all image types that are wrapped. + foreach(t ${types}) + if(NOT DEFINED ITKT_I${t}${d}) + list(REMOVE_ITEM types ${t}) + endif() + endforeach() + + foreach(t ${types}) + # Wraps RGB and RGBA types that have been selected to be wrapped. + # We have to recompute them all to extract the pixel component type. + if(WRAP_ITK_RGB AND DEFINED ITKT_IRGB${t}${d}) + itk_wrap_template("${ITKM_IRGB${t}${d}}${ITKM_I${t}${d}}" + "${ITKT_IRGB${t}${d}}, ${ITKT_I${t}${d}}, 3" + ) + endif() + if(WRAP_ITK_RGBA AND DEFINED ITKT_IRGBA${t}${d}) + itk_wrap_template("${ITKM_IRGBA${t}${d}}${ITKM_I${t}${d}}" + "${ITKT_IRGBA${t}${d}}, ${ITKT_I${t}${d}}, 4" + ) + endif() endforeach() endforeach() itk_end_wrap_class() From e2815d5ed4841b033fec28ed9c274e530d96f869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sun, 24 Mar 2019 19:30:56 -0400 Subject: [PATCH 31/47] STYLE: Prefer = default to explicitly trivial implementations This check replaces default bodies of special member functions with `= default;`. The explicitly defaulted function declarations enable more opportunities in optimization, because the compiler might treat explicitly defaulted functions as trivial. Additionally, the C++11 use of `= default` more clearly expresses the intent for the special member functions. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 5d09db5863b..17724523144 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -84,7 +84,7 @@ class ITK_TEMPLATE_EXPORT SplitComponentsImageFilter : public ImageToImageFilter protected: SplitComponentsImageFilter(); - ~SplitComponentsImageFilter() override {} + ~SplitComponentsImageFilter() override = default; /** Do not allocate outputs that we will not populate. */ void From d8d896b2fc39815cdd88e5de189ae25d99ea03e3 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Wed, 19 Feb 2020 10:45:27 -0600 Subject: [PATCH 32/47] DOC: Update copyright assignment to NumFOCUS The mission of NumFOCUS is to promote open practices in research, data, and scientific computing. https://numfocus.org --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- .../SplitComponents/include/itkSplitComponentsImageFilter.hxx | 2 +- .../SplitComponents/test/itkSplitComponentsImageFilterTest.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 17724523144..b435c6d7315 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index fb0354ffe02..34bcd885ca3 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx index 9fc29efa991..41d680ce38b 100644 --- a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 22fd20fc4dd12a56bb9f6e9069a482ec06cd8b08 Mon Sep 17 00:00:00 2001 From: Mathew Seng Date: Fri, 16 Oct 2020 09:53:12 -0500 Subject: [PATCH 33/47] STYLE: Rename ITK_DISALLOW_COPY_AND_ASSIGN to ITK_DISALLOW_COPY_AND_MOVE Fixes changes made in #2053. ITK_DISALLOW_COPY_AND_ASSIGN will be used if ITK_FUTURE_LEGACY_REMOVE=OFF. --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index b435c6d7315..9d325b5c550 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -48,7 +48,7 @@ template { public: - ITK_DISALLOW_COPY_AND_ASSIGN(SplitComponentsImageFilter); + ITK_DISALLOW_COPY_AND_MOVE(SplitComponentsImageFilter); /** ImageDimension enumeration. */ static constexpr unsigned int ImageDimension = TInputImage::ImageDimension; From 224c86a4fda914af79ba1345b8fa672e6ab310f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Tue, 5 Jan 2021 12:33:36 -0500 Subject: [PATCH 34/47] ENH: fix the wrapping Closes #33. Closes #41. The error messages were: itkSplitComponentsImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageToImageFilter< itk::Image< itk::Vector< double, 2 >, 2 >, itk::Image< double, 2 > > itkSplitComponentsImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageToImageFilter< itk::Image< itk::Vector< double, 3 >, 3 >, itk::Image< double, 3 > > itkSplitComponentsImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageToImageFilter< itk::Image< itk::Vector< double, 4 >, 4 >, itk::Image< double, 4 > > --- .../itkSplitComponentsImageFilter.wrap | 66 +++++++++++++------ 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap index 1244b3c1c16..ce569d01909 100644 --- a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -1,39 +1,63 @@ itk_wrap_class("itk::SplitComponentsImageFilter" POINTER) -# We can only wrap types that have been wrapped for -# ImageToImageFilter (parent class). -unique(types "${WRAP_ITK_REAL};UC") + +# Vector -> scalar +set(types ${WRAP_ITK_INT}) +if(ITK_WRAP_vector_float) + list(APPEND types "F") +endif() +if(ITK_WRAP_vector_double) + list(APPEND types "D") +endif() foreach(d ${ITK_WRAP_IMAGE_DIMS}) foreach(t ${types}) if(DEFINED ITKT_IV${t}${d}${d}) itk_wrap_template( - "${ITKM_IV${t}${d}${d}}${ITKM_I${t}${d}}" - "${ITKT_IV${t}${d}${d}}, ${ITKT_I${t}${d}}" + "${ITKM_IV${t}${d}${d}}${ITKM_I${t}${d}}" + "${ITKT_IV${t}${d}${d}}, ${ITKT_I${t}${d}}" ) endif() endforeach() endforeach() + +# CovariantVector -> scalar +set(types ${WRAP_ITK_INT}) +if(ITK_WRAP_covariant_vector_float) + list(APPEND types "F") +endif() +if(ITK_WRAP_covariant_vector_double) + list(APPEND types "D") +endif() foreach(d ${ITK_WRAP_IMAGE_DIMS}) - unique(types "${WRAP_ITK_SCALAR};UC;D;US;UI;UL;SC;SS;SI;SL;F") - # Define filter for all image types that are wrapped. foreach(t ${types}) - if(NOT DEFINED ITKT_I${t}${d}) - list(REMOVE_ITEM types ${t}) + if(DEFINED ITKT_IV${t}${d}${d}) + itk_wrap_template( + "${ITKM_ICV${t}${d}${d}}${ITKM_I${t}${d}}" + "itk::Image, ${d}>, ${ITKT_I${t}${d}}" + ) endif() endforeach() +endforeach() +# VectorImage -> scalar +unique(types "${WRAP_ITK_SCALAR}") +foreach(d ${ITK_WRAP_IMAGE_DIMS}) foreach(t ${types}) - # Wraps RGB and RGBA types that have been selected to be wrapped. - # We have to recompute them all to extract the pixel component type. - if(WRAP_ITK_RGB AND DEFINED ITKT_IRGB${t}${d}) - itk_wrap_template("${ITKM_IRGB${t}${d}}${ITKM_I${t}${d}}" - "${ITKT_IRGB${t}${d}}, ${ITKT_I${t}${d}}, 3" - ) - endif() - if(WRAP_ITK_RGBA AND DEFINED ITKT_IRGBA${t}${d}) - itk_wrap_template("${ITKM_IRGBA${t}${d}}${ITKM_I${t}${d}}" - "${ITKT_IRGBA${t}${d}}, ${ITKT_I${t}${d}}, 4" - ) - endif() + itk_wrap_template("${ITKM_VI${t}${d}}${ITKM_I${t}${d}}" "${ITKT_VI${t}${d}},${ITKT_I${t}${d}}") endforeach() endforeach() + +# RGB(A) -> scalar +if(ITK_WRAP_rgb_unsigned_char AND ITK_WRAP_unsigned_char) + itk_wrap_image_filter_types(RGBUC UC) +endif() +if(ITK_WRAP_rgb_unsigned_short AND ITK_WRAP_unsigned_short) + itk_wrap_image_filter_types(RGBUS US) +endif() +if(ITK_WRAP_rgba_unsigned_char AND ITK_WRAP_unsigned_char) + itk_wrap_image_filter_types(RGBAUC UC) +endif() +if(ITK_WRAP_rgba_unsigned_short AND ITK_WRAP_unsigned_short) + itk_wrap_image_filter_types(RGBAUS US) +endif() + itk_end_wrap_class() From ba06d7f2106d439a8b120c10e356e1490feeac8e Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Fri, 17 Dec 2021 12:44:19 -0600 Subject: [PATCH 35/47] COMP: Remove inclusion of .hxx files as headers The ability to include either .h or .hxx files as header files required recursively reading the .h files twice. The added complexity is unnecessary, costly, and can confuse static analysis tools that monitor header guardes (due to reaching the maximum depth of recursion limits for nested #ifdefs in checking). --- .../SplitComponents/include/itkSplitComponentsImageFilter.hxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index 34bcd885ca3..a0fc7779a31 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -18,7 +18,6 @@ #ifndef itkSplitComponentsImageFilter_hxx #define itkSplitComponentsImageFilter_hxx -#include "itkSplitComponentsImageFilter.h" #include "itkImageRegionConstIterator.h" #include "itkImageRegionIterator.h" From 1cc0400040f0cc21de160f44d886f22d1ab34c9f Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Tue, 31 May 2022 13:34:56 -0400 Subject: [PATCH 36/47] ENH: Bump ITK and change http to https --- Modules/Filtering/SplitComponents/LICENSE | 4 ++-- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- .../SplitComponents/include/itkSplitComponentsImageFilter.hxx | 2 +- .../test/itkSplitComponentsImageFilterTest.cxx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Filtering/SplitComponents/LICENSE b/Modules/Filtering/SplitComponents/LICENSE index d6456956733..62589edd12a 100644 --- a/Modules/Filtering/SplitComponents/LICENSE +++ b/Modules/Filtering/SplitComponents/LICENSE @@ -1,7 +1,7 @@ Apache License Version 2.0, January 2004 - http://www.apache.org/licenses/ + https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -193,7 +193,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index 9d325b5c550..a3f1b4f8d77 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx index a0fc7779a31..86cedb07515 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.hxx @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx index 41d680ce38b..580cb2483ac 100644 --- a/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx +++ b/Modules/Filtering/SplitComponents/test/itkSplitComponentsImageFilterTest.cxx @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0.txt + * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, From 28522c1362a8108b2109e08e6fbb16404657e851 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Wed, 6 Jul 2022 08:45:36 -0400 Subject: [PATCH 37/47] COMP: Bump to minimum CMake 3.16.3 --- Modules/Filtering/SplitComponents/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index e6cb378d823..00e1c3b0e75 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.16.3) project(SplitComponents) # set(SplitComponents_LIBRARIES SplitComponents) # header-only module, so no libraries From 4f88f094fdee48b7611a837cd26eddc4a7e0c057 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Thu, 5 Jan 2023 13:15:59 -0500 Subject: [PATCH 38/47] BUG: Address Python notebook test failures Resolves issues identified in automated Python notebook testing: - The number of components to split with `SplitComponentsImageFilter` is now fixed at 3 for RGB and 4 for RGBA images rather than being defined by the image dimension. Under previous behavior only the first two RG components could be extracted for a 2D image. - Updated to use pythonic `itk.image_duplicator` - Downgrades `traitlets` for compatibility with `itkwidgets==0.32.5` Also updates `.gitignore` to ignore example artifacts. --- .../itkSplitComponentsImageFilter.wrap | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap index ce569d01909..cd0d11e3957 100644 --- a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -48,16 +48,26 @@ endforeach() # RGB(A) -> scalar if(ITK_WRAP_rgb_unsigned_char AND ITK_WRAP_unsigned_char) - itk_wrap_image_filter_types(RGBUC UC) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_RGBUC}${d}I${ITKM_UC}${d}3" "itk::Image<${ITKT_RGBUC},${d}>,itk::Image<${ITKT_UC},${d}>,3") + endforeach() endif() if(ITK_WRAP_rgb_unsigned_short AND ITK_WRAP_unsigned_short) - itk_wrap_image_filter_types(RGBUS US) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_RGBUS}${d}I${ITKM_US}${d}3" "itk::Image<${ITKT_RGBUS},${d}>,itk::Image<${ITKT_US},${d}>,3") + endforeach() + itk_wrap_image_filter_types(RGBUS US 3) endif() if(ITK_WRAP_rgba_unsigned_char AND ITK_WRAP_unsigned_char) - itk_wrap_image_filter_types(RGBAUC UC) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_RGBAUC}${d}I${ITKM_UC}${d}3" "itk::Image<${ITKT_RGBAUC},${d}>,itk::Image<${ITKT_UC},${d}>,4") + endforeach() + itk_wrap_image_filter_types(RGBAUC UC 4) endif() if(ITK_WRAP_rgba_unsigned_short AND ITK_WRAP_unsigned_short) - itk_wrap_image_filter_types(RGBAUS US) + foreach(d ${ITK_WRAP_IMAGE_DIMS}) + itk_wrap_template("I${ITKM_RGBAUS}${d}I${ITKM_US}${d}3" "itk::Image<${ITKT_RGBAUS},${d}>,itk::Image<${ITKT_US},${d}>,4") + endforeach() endif() itk_end_wrap_class() From 6f9e8c836df09bbda00bd893b292c0976058cf17 Mon Sep 17 00:00:00 2001 From: Tom Birdsong Date: Fri, 20 Jan 2023 11:54:25 -0500 Subject: [PATCH 39/47] BUG: Resolve CMP135 Warning Resolves CMake warning regarding CMP135 policy introduced in CMake 3.24 --- Modules/Filtering/SplitComponents/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index 00e1c3b0e75..f8ca6ec5a66 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16.3) project(SplitComponents) +if(POLICY CMP135) + cmake_policy(SET CMP135 NEW) +endif() + # set(SplitComponents_LIBRARIES SplitComponents) # header-only module, so no libraries itk_module_impl() From 891b479c305fb163a3925d55a584b00033553046 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Sun, 26 Jan 2025 09:01:44 -0600 Subject: [PATCH 40/47] STYLE: Add itkVirtualGetNameOfClassMacro + itkOverrideGetNameOfClassMacro Added two new macro's, intended to replace the old 'itkTypeMacro' and 'itkTypeMacroNoParent'. The main aim is to be clearer about what those macro's do: add a virtual 'GetNameOfClass()' member function and override it. Unlike 'itkTypeMacro', 'itkOverrideGetNameOfClassMacro' does not have a 'superclass' parameter, as it was not used anyway. Note that originally 'itkTypeMacro' did not use its 'superclass' parameter either, looking at commit 699b66cb04d410e555656828e8892107add38ccb, Will Schroeder, June 27, 2001: https://github.com/InsightSoftwareConsortium/ITK/blob/699b66cb04d410e555656828e8892107add38ccb/Code/Common/itkMacro.h#L331-L337 --- .../SplitComponents/include/itkSplitComponentsImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h index a3f1b4f8d77..40a89b2ae11 100644 --- a/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h +++ b/Modules/Filtering/SplitComponents/include/itkSplitComponentsImageFilter.h @@ -71,7 +71,7 @@ class ITK_TEMPLATE_EXPORT SplitComponentsImageFilter : public ImageToImageFilter using ComponentsMaskType = FixedArray; /** Run-time type information (and related methods). */ - itkTypeMacro(SplitComponentsImageFilter, ImageToImageFilter); + itkOverrideGetNameOfClassMacro(SplitComponentsImageFilter); /** Method of creation through the object factory. */ itkNewMacro(Self); From bf4003966698e0237db6b7920da803ae10655d79 Mon Sep 17 00:00:00 2001 From: Bradley Lowekamp Date: Tue, 27 Jan 2026 15:42:25 +0000 Subject: [PATCH 41/47] BUG: Fix test variable names for remote module Remove ITK prefix from variable names as it's for internal ITK modules. Use correct SplitComponents-Test_LIBRARIES instead of ITKSplitComponents-Test_LIBRARIES. Update test driver name and related variables accordingly. --- Modules/Filtering/SplitComponents/test/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/Filtering/SplitComponents/test/CMakeLists.txt b/Modules/Filtering/SplitComponents/test/CMakeLists.txt index 784e49d32b2..011863b43be 100644 --- a/Modules/Filtering/SplitComponents/test/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/test/CMakeLists.txt @@ -1,13 +1,11 @@ itk_module_test() -set(ITKSplitComponentsTests itkSplitComponentsImageFilterTest.cxx) -createtestdriver( ITKSplitComponents "${ITKSplitComponents-Test_LIBRARIES}" "${ITKSplitComponentsTests}") - -set(TEMP ${ITK_TEST_OUTPUT_DIR}) +set(SplitComponentsTests itkSplitComponentsImageFilterTest.cxx) +createtestdriver( SplitComponents "${SplitComponents-Test_LIBRARIES}" "${SplitComponentsTests}") itk_add_test( NAME itkSplitComponentsImageFilterTest COMMAND - ITKSplitComponentsTestDriver + SplitComponentsTestDriver --compare DATA{Baseline/itkSplitComponentsImageFilterTestBaseline0.mha} itkSplitComponentsImageFilterTestOutput0.mha From 7cbb25ef7bbf53dfdfd799dea401dd6afc326735 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 22 Apr 2026 18:54:53 -0500 Subject: [PATCH 42/47] ENH: Convert from md5 to .cid tags. --- .../Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.cid | 1 + .../Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 | 1 - .../Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.cid | 1 + .../Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.cid delete mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 create mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.cid delete mode 100644 Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.cid b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.cid new file mode 100644 index 00000000000..ed8a272d63d --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.cid @@ -0,0 +1 @@ +bafkreiamxu2cy6vfjc6t5fsvcdaeqn36chmnpnimtcnlxnmy5z3tjmaghe diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 deleted file mode 100644 index 29653c0ffb0..00000000000 --- a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline0.mha.md5 +++ /dev/null @@ -1 +0,0 @@ -a3519cb25bb2bfeda9d976da2f9707cd diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.cid b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.cid new file mode 100644 index 00000000000..19ace7c16bc --- /dev/null +++ b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.cid @@ -0,0 +1 @@ +bafkreif3tkgmecbfvioj3ijohqdre77nfzf6foimlcxlscr5ud54qsooqe diff --git a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 b/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 deleted file mode 100644 index aa1a188ae55..00000000000 --- a/Modules/Filtering/SplitComponents/test/Baseline/itkSplitComponentsImageFilterTestBaseline1.mha.md5 +++ /dev/null @@ -1 +0,0 @@ -b53699740d1fafd85bd66a9df0c23b5a From 9765a0742907dc0caba8986e3bc5ae0a4447f50a Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 5 May 2026 07:11:07 -0500 Subject: [PATCH 43/47] DOC: Add SplitComponents module README pointing at archived upstream --- Modules/Filtering/SplitComponents/README.md | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Modules/Filtering/SplitComponents/README.md diff --git a/Modules/Filtering/SplitComponents/README.md b/Modules/Filtering/SplitComponents/README.md new file mode 100644 index 00000000000..289f740b4a0 --- /dev/null +++ b/Modules/Filtering/SplitComponents/README.md @@ -0,0 +1,41 @@ +# SplitComponents + +In-tree ITK module providing `itk::SplitComponentsImageFilter` — a +filter that splits a vector / covariant-vector / symmetric-second-rank- +tensor image into one scalar component image per pixel-component. +Useful for visualising, post-processing, or independently filtering +the channels of multi-component images. + +## Origin + +Ingested from the standalone remote module +[**InsightSoftwareConsortium/ITKSplitComponents**](https://github.com/InsightSoftwareConsortium/ITKSplitComponents) +on 2026-05-05, at upstream commit +[`94fde65c`](https://github.com/InsightSoftwareConsortium/ITKSplitComponents/commit/94fde65cae6883c9a0f1508c37c501c2ad989cdd). +The upstream repository will be archived read-only after this PR +merges; it remains reachable at the URL above. + +## What lives here + +Per the v4 ingestion strategy (see +`Utilities/Maintenance/RemoteModuleIngest/INGESTION_STRATEGY_v4.md`), +only paths matching the narrow whitelist +(`Utilities/Maintenance/RemoteModuleIngest/whitelists/SplitComponents.list`) +crossed the merge boundary: + +- `include/` — public C++ headers (header-only module; no `src/`). +- `test/` — CTest drivers and content-link stubs. +- `wrapping/` — Python wrapping descriptors. +- `CMakeLists.txt`, `itk-module.cmake` — module metadata. +- `LICENSE` — original Apache-2.0 license text. + +Upstream-only artifacts (CI dashboards, packaging, `apps/`, +`article/`, `binder/`, `examples/`, `images/`, `.github/`, +`pyproject.toml`, etc.) were explicitly excluded; the upstream +commit graph and authorship history are otherwise preserved through +a `--no-ff --allow-unrelated-histories` Mode-A merge. + +## Building + +SplitComponents is enabled by default once `Module_SplitComponents=ON` +is set; in CI it is enabled via `pyproject.toml`'s `configure-ci` task. From 764894507b0453a36c3e7878e0acbca500cbc0a0 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 5 May 2026 07:11:11 -0500 Subject: [PATCH 44/47] COMP: Remove SplitComponents remote-fetch cmake (now in-tree) The module now lives under Modules/Filtering/SplitComponents/. Drop the configure-time fetch entry; consumers enable the module via Module_SplitComponents=ON like any other in-tree module. --- Modules/Remote/SplitComponents.remote.cmake | 54 --------------------- 1 file changed, 54 deletions(-) delete mode 100644 Modules/Remote/SplitComponents.remote.cmake diff --git a/Modules/Remote/SplitComponents.remote.cmake b/Modules/Remote/SplitComponents.remote.cmake deleted file mode 100644 index 7bd2a7b3bc2..00000000000 --- a/Modules/Remote/SplitComponents.remote.cmake +++ /dev/null @@ -1,54 +0,0 @@ -#-- # Grading Level Criteria Report -#-- EVALUATION DATE: 2020-03-01 -#-- EVALUATORS: [<>,<>] -#-- -#-- ## Compliance level 5 star (AKA ITK main modules, or remote modules that could become core modules) -#-- - [ ] Widespread community dependance -#-- - [ ] Above 90% code coverage -#-- - [ ] CI dashboards and testing monitored rigorously -#-- - [ ] Key API features are exposed in wrapping interface -#-- - [ ] All requirements of Levels 4,3,2,1 -#-- -#-- ## Compliance Level 4 star (Very high-quality code, perhaps small community dependance) -#-- - [ ] Meets all ITK code style standards -#-- - [ ] No external requirements beyond those needed by ITK proper -#-- - [ ] Builds and passes tests on all supported platforms within 1 month of each core tagged release -#-- - [ ] Windows Shared Library Build with Visual Studio -#-- - [ ] Mac with clang compiller -#-- - [ ] Linux with gcc compiler -#-- - [ ] Active developer community dedicated to maintaining code-base -#-- - [ ] 75% code coverage demonstrated for testing suite -#-- - [ ] Continuous integration testing performed -#-- - [ ] All requirements of Levels 3,2,1 -#-- -#-- ## Compliance Level 3 star (Quality beta code) -#-- - [ ] API | executable interface is considered mostly stable and feature complete -#-- - [ ] 10% C0-code coverage demonstrated for testing suite -#-- - [ ] Some tests exist and pass on at least some platform -#-- - [X] All requirements of Levels 2,1 -#-- -#-- ## Compliance Level 2 star (Alpha code feature API development or niche community/execution environment dependance ) -#-- - [X] Compiles for at least 1 niche set of execution envirionments, and perhaps others -#-- (may depend on specific external tools like a java environment, or specific external libraries to work ) -#-- - [X] All requirements of Levels 1 -#-- -#-- ## Compliance Level 1 star (Pre-alpha features under development and code of unknown quality) -#-- - [X] Code complies on at least 1 platform -#-- -#-- ## Compliance Level 0 star ( Code/Feature of known poor-quality or deprecated status ) -#-- - [ ] Code reviewed and explicitly identified as not recommended for use -#-- -#-- ### Please document here any justification for the criteria above -# Code style enforced by clang-format on 2020-02-19, and clang-tidy modernizations completed - -# Contact: Matt McCormick -itk_fetch_module( - SplitComponents - "This module contains filter called -itk::SplitComponentsImageFilter. This filter generates component images from an -itk::Image of, for example, itk::Vector, itk::CovariantVector, or -itk::SymmetricSecondRankTensor. https://doi.org/10.54294/4c92vb" - MODULE_COMPLIANCE_LEVEL 2 - GIT_REPOSITORY https://github.com/InsightSoftwareConsortium/ITKSplitComponents.git - GIT_TAG 7a1e19d1f798e58929344f69dcd371b82c28fba7 - ) From 3de059ad5d953824cf56fddc2bf68fba34c6472a Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 5 May 2026 07:11:13 -0500 Subject: [PATCH 45/47] ENH: Enable Module_SplitComponents in configure-ci pixi task Now that SplitComponents is in-tree under Modules/Filtering/SplitComponents/, exercise it on every pixi configure-ci run (Linux / macOS / Windows GitHub Actions matrix). --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 52c56027848..dc52f518a37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ cmd = '''cmake -DModule_LabelErodeDilate:BOOL=ON -DModule_MeshNoise:BOOL=ON -DModule_MGHIO:BOOL=ON + -DModule_SplitComponents:BOOL=ON -DITK_COMPUTER_MEMORY_SIZE:STRING=11 -DModule_StructuralSimilarity:BOOL=ON''' description = "Configure ITK for CI (with ccache compiler launcher)" From dfcb7d23a08fcedbf48ebfa4da6f495f92448223 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 5 May 2026 08:33:00 -0500 Subject: [PATCH 46/47] BUG: Fix SplitComponentsImageFilter wrapping (Greptile review) Two upstream wrapping bugs caught by Greptile review on PR #6212: 1. CovariantVector wrap block guarded on ITKT_IV (Vector image type prefix) instead of ITKT_ICV (CovariantVector image type prefix). In a configuration with ITK_WRAP_covariant_vector_float=OFF and ITK_WRAP_vector_float=ON this would emit dangling itk_wrap_template calls referencing undefined CovariantVector types. 2. Removed two redundant itk_wrap_image_filter_types(...) calls that followed the per-dimension foreach loops in the ITK_WRAP_rgb_unsigned_short and ITK_WRAP_rgba_unsigned_char branches. The macros iterate over all enabled dimensions, so the trailing call duplicated registrations. The asymmetric structure (only those two branches had the duplicate; rgb_unsigned_char and rgba_unsigned_short already lacked it) confirms a copy-paste artifact upstream. --- .../wrapping/itkSplitComponentsImageFilter.wrap | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap index cd0d11e3957..bb6b88890dd 100644 --- a/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap +++ b/Modules/Filtering/SplitComponents/wrapping/itkSplitComponentsImageFilter.wrap @@ -29,7 +29,7 @@ if(ITK_WRAP_covariant_vector_double) endif() foreach(d ${ITK_WRAP_IMAGE_DIMS}) foreach(t ${types}) - if(DEFINED ITKT_IV${t}${d}${d}) + if(DEFINED ITKT_ICV${t}${d}${d}) itk_wrap_template( "${ITKM_ICV${t}${d}${d}}${ITKM_I${t}${d}}" "itk::Image, ${d}>, ${ITKT_I${t}${d}}" @@ -56,13 +56,11 @@ if(ITK_WRAP_rgb_unsigned_short AND ITK_WRAP_unsigned_short) foreach(d ${ITK_WRAP_IMAGE_DIMS}) itk_wrap_template("I${ITKM_RGBUS}${d}I${ITKM_US}${d}3" "itk::Image<${ITKT_RGBUS},${d}>,itk::Image<${ITKT_US},${d}>,3") endforeach() - itk_wrap_image_filter_types(RGBUS US 3) endif() if(ITK_WRAP_rgba_unsigned_char AND ITK_WRAP_unsigned_char) foreach(d ${ITK_WRAP_IMAGE_DIMS}) itk_wrap_template("I${ITKM_RGBAUC}${d}I${ITKM_UC}${d}3" "itk::Image<${ITKT_RGBAUC},${d}>,itk::Image<${ITKT_UC},${d}>,4") endforeach() - itk_wrap_image_filter_types(RGBAUC UC 4) endif() if(ITK_WRAP_rgba_unsigned_short AND ITK_WRAP_unsigned_short) foreach(d ${ITK_WRAP_IMAGE_DIMS}) From 4347edecc0fd5b62ef97d1119c353cd1e1648b50 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 5 May 2026 11:27:30 -0500 Subject: [PATCH 47/47] COMP: Drop dead cmake_minimum_required from SplitComponents CMakeLists In-tree, ITK's top-level CMakeLists pins the CMake minimum, so the per-module declaration is dead code. Matches the v4 ingest-pipeline rule in PR #6204 (sanitize-history.py:patch_drop_cmake_minimum_required). --- Modules/Filtering/SplitComponents/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Filtering/SplitComponents/CMakeLists.txt b/Modules/Filtering/SplitComponents/CMakeLists.txt index f8ca6ec5a66..7172c118dba 100644 --- a/Modules/Filtering/SplitComponents/CMakeLists.txt +++ b/Modules/Filtering/SplitComponents/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.16.3) project(SplitComponents) if(POLICY CMP135)