diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml index d13527c..efac9f6 100644 --- a/.github/workflows/build-test-package.yml +++ b/.github/workflows/build-test-package.yml @@ -3,263 +3,9 @@ name: Build, test, package on: [push,pull_request] jobs: - build-test-cxx: - runs-on: ${{ matrix.os }} - strategy: - max-parallel: 3 - matrix: - os: [ubuntu-18.04, windows-2019, macos-10.15] - include: - - os: ubuntu-18.04 - c-compiler: "gcc" - cxx-compiler: "g++" - itk-git-tag: "v5.1.1" - cmake-build-type: "MinSizeRel" - - os: windows-2019 - c-compiler: "cl.exe" - cxx-compiler: "cl.exe" - itk-git-tag: "v5.1.1" - cmake-build-type: "Release" - - os: macos-10.15 - c-compiler: "clang" - cxx-compiler: "clang++" - itk-git-tag: "v5.1.1" - cmake-build-type: "MinSizeRel" - - steps: - - uses: actions/checkout@v1 - - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - - name: Install build dependencies - run: | - python -m pip install --upgrade pip - python -m pip install ninja - - - name: Download ITK - run: | - cd .. - git clone https://github.com/InsightSoftwareConsortium/ITK.git - cd ITK - git checkout ${{ matrix.itk-git-tag }} - - - name: Build ITK - if: matrix.os != 'windows-2019' - run: | - cd .. - mkdir ITK-build - cd ITK-build - cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK - ninja - - - name: Build ITK - if: matrix.os == 'windows-2019' - run: | - cd .. - mkdir ITK-build - cd ITK-build - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK - ninja - shell: cmd - - - name: Fetch CTest driver script - run: | - curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O - - - name: Configure CTest script - shell: bash - run: | - operating_system="${{ matrix.os }}" - cat > dashboard.cmake << EOF - set(CTEST_SITE "GitHubActions") - file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT) - file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/" CTEST_SOURCE_DIRECTORY) - file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY) - set(dashboard_source_name "${GITHUB_REPOSITORY}") - if(ENV{GITHUB_REF} MATCHES "master") - set(branch "-master") - set(dashboard_model "Continuous") - else() - set(branch "-${GITHUB_REF}") - set(dashboard_model "Experimental") - endif() - set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}") - set(CTEST_UPDATE_VERSION_ONLY 1) - set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL}) - set(CTEST_BUILD_CONFIGURATION "Release") - set(CTEST_CMAKE_GENERATOR "Ninja") - set(CTEST_CUSTOM_WARNING_EXCEPTION - \${CTEST_CUSTOM_WARNING_EXCEPTION} - # macOS Azure VM Warning - "ld: warning: text-based stub file" - ) - set(dashboard_no_clean 1) - set(ENV{CC} ${{ matrix.c-compiler }}) - set(ENV{CXX} ${{ matrix.cxx-compiler }}) - set(dashboard_cache " - ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build - BUILD_TESTING:BOOL=ON - ") - string(TIMESTAMP build_date "%Y-%m-%d") - message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}") - message("CTEST_SITE = \${CTEST_SITE}") - include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) - EOF - cat dashboard.cmake - - - name: Build and test - if: matrix.os != 'windows-2019' - run: | - ctest --output-on-failure -j 2 -V -S dashboard.cmake - - - name: Build and test - if: matrix.os == 'windows-2019' - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - ctest --output-on-failure -j 2 -V -S dashboard.cmake - shell: cmd - - build-linux-python-packages: - runs-on: ubuntu-18.04 - strategy: - max-parallel: 2 - matrix: - python-version: [35, 36, 37, 38] - include: - - itk-python-git-tag: "v5.1.1" - - steps: - - uses: actions/checkout@v2 - - - name: 'Free up disk space' - run: | - # Workaround for https://github.com/actions/virtual-environments/issues/709 - df -h - sudo apt-get clean - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - df -h - - - name: 'Fetch build script' - run: | - curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O - chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh - - - name: 'Build 🐍 Python 📦 package' - run: | - export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }} - ./dockcross-manylinux-download-cache-and-build-module-wheels.sh cp${{ matrix.python-version }} - - - name: Publish Python package as GitHub Artifact - uses: actions/upload-artifact@v1 - with: - name: LinuxWheel${{ matrix.python-version }} - path: dist - - build-macos-python-packages: - runs-on: macos-10.15 - strategy: - max-parallel: 2 - matrix: - include: - - itk-python-git-tag: "v5.1.1" - - steps: - - uses: actions/checkout@v2 - - - name: 'Fetch build script' - run: | - curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O - chmod u+x macpython-download-cache-and-build-module-wheels.sh - - - name: 'Build 🐍 Python 📦 package' - run: | - export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }} - export MACOSX_DEPLOYMENT_TARGET=10.9 - ./macpython-download-cache-and-build-module-wheels.sh - - - name: Publish Python package as GitHub Artifact - uses: actions/upload-artifact@v1 - with: - name: MacOSWheels - path: dist - - build-windows-python-packages: - runs-on: windows-2019 - strategy: - max-parallel: 2 - matrix: - python-version-minor: [5, 6, 7, 8] - include: - - itk-python-git-tag: "v5.1.1" - - steps: - - uses: actions/checkout@v2 - with: - path: "im" - - - name: 'Install Python' - run: | - $pythonArch = "64" - $pythonVersion = "3.${{ matrix.python-version-minor }}" - iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1')) - - - name: 'Fetch build dependencies' - shell: bash - run: | - mv im ../../ - cd ../../ - curl -L "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${{ matrix.itk-python-git-tag }}/ITKPythonBuilds-windows.zip" -o "ITKPythonBuilds-windows.zip" - 7z x ITKPythonBuilds-windows.zip -o/c/P -aoa -r - curl -L "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -o "doxygen-1.8.11.windows.bin.zip" - 7z x doxygen-1.8.11.windows.bin.zip -o/c/P/doxygen -aoa -r - curl -L "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -o "grep-win.zip" - 7z x grep-win.zip -o/c/P/grep -aoa -r - - - name: 'Build 🐍 Python 📦 package' - shell: cmd - run: | - cd ../../im - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - set PATH="C:\P\grep;%PATH%" - set CC=cl.exe - set CXX=cl.exe - C:\Python3${{ matrix.python-version-minor }}-x64\python.exe C:\P\IPP\scripts\windows_build_module_wheels.py --py-envs "3${{ matrix.python-version-minor }}-x64" - - - name: Publish Python package as GitHub Artifact - uses: actions/upload-artifact@v1 - with: - name: WindowWheel3.${{ matrix.python-version-minor }} - path: ../../im/dist - - publish-python-packages-to-pypi: - needs: - - build-linux-python-packages - - build-macos-python-packages - - build-windows-python-packages - runs-on: ubuntu-18.04 - - steps: - - name: Download Python Packages - uses: actions/download-artifact@v2 - - - name: Prepare packages for upload - run: | - ls -R - for d in */; do - mv ${d}/*.whl . - done - mkdir dist - mv *.whl dist/ - ls dist - - - name: Publish 🐍 Python 📦 package to PyPI - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} + cxx-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-cxx.yml@5083da2740617b78423ebf6083489e1e70ee8ca0 + python-build-workflow: + uses: InsightSoftwareConsortium/ITKRemoteModuleBuildTestPackageAction/.github/workflows/build-test-package-python.yml@5083da2740617b78423ebf6083489e1e70ee8ca0 + secrets: + pypi_password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/clang-format-linter.yml b/.github/workflows/clang-format-linter.yml index 69166d9..899d579 100644 --- a/.github/workflows/clang-format-linter.yml +++ b/.github/workflows/clang-format-linter.yml @@ -7,7 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 + - uses: actions/checkout@v3 + - uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@master diff --git a/LICENSE b/LICENSE index d645695..62589ed 100644 --- a/LICENSE +++ b/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/include/itkDICOMOrientImageFilter.h b/include/itkDICOMOrientImageFilter.h index 328fe98..d2ecb3d 100644 --- a/include/itkDICOMOrientImageFilter.h +++ b/include/itkDICOMOrientImageFilter.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, @@ -62,11 +62,10 @@ namespace itk * \ingroup SimpleITKFilters */ template -class ITK_TEMPLATE_EXPORT DICOMOrientImageFilter - : public ImageToImageFilter +class ITK_TEMPLATE_EXPORT DICOMOrientImageFilter : public ImageToImageFilter { public: - ITK_DISALLOW_COPY_AND_ASSIGN(DICOMOrientImageFilter); + ITK_DISALLOW_COPY_AND_MOVE(DICOMOrientImageFilter); /** Standard class type aliases. */ using Self = DICOMOrientImageFilter; @@ -140,7 +139,7 @@ class ITK_TEMPLATE_EXPORT DICOMOrientImageFilter void GenerateOutputInformation() override; - static_assert(ImageDimension == 3, "Only 3 dimensional images are support!" ); + static_assert(ImageDimension == 3, "Only 3 dimensional images are support!"); protected: DICOMOrientImageFilter(); @@ -154,7 +153,7 @@ class ITK_TEMPLATE_EXPORT DICOMOrientImageFilter /*** Member functions used by GenerateData: */ void - DeterminePermutationsAndFlips(DICOMOrientation desired, DICOMOrientation given); + DeterminePermutationsAndFlips(DICOMOrientation desired, DICOMOrientation given); /** Returns true if a permute is required. Returns false otherwise. */ bool diff --git a/include/itkDICOMOrientImageFilter.hxx b/include/itkDICOMOrientImageFilter.hxx index 9468ba2..b8e2ed8 100644 --- a/include/itkDICOMOrientImageFilter.hxx +++ b/include/itkDICOMOrientImageFilter.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, @@ -29,7 +29,7 @@ namespace itk template DICOMOrientImageFilter::DICOMOrientImageFilter() - : m_FlipAxes{false} + : m_FlipAxes{ false } { for (unsigned int dimension = 0; dimension < ImageDimension; ++dimension) { @@ -159,7 +159,7 @@ DICOMOrientImageFilter::SetDesiredCoordinateOrientation(const std:: { DICOMOrientation o(desired); - if ( OrientationEnum(o) == OrientationEnum::INVALID) + if (OrientationEnum(o) == OrientationEnum::INVALID) { itkWarningMacro("Invalid desired coordinate direction string: \"" << desired << "\"!"); } @@ -301,7 +301,7 @@ DICOMOrientImageFilter::VerifyPreconditions() ITKv5_CONST if (this->m_DesiredCoordinateOrientation == OrientationEnum::INVALID) { - itkExceptionMacro(<<"DesiredCoordinateOrientation is 'INVALID'.") + itkExceptionMacro(<< "DesiredCoordinateOrientation is 'INVALID'."); } } diff --git a/include/itkDICOMOrientation.h b/include/itkDICOMOrientation.h index 8034df2..9e03b5f 100644 --- a/include/itkDICOMOrientation.h +++ b/include/itkDICOMOrientation.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, @@ -216,7 +216,7 @@ class SimpleITKFilters_EXPORT DICOMOrientation friend SimpleITKFilters_EXPORT std::ostream & - operator<<(std::ostream & out, OrientationEnum value); + operator<<(std::ostream & out, OrientationEnum value); private: diff --git a/include/itkHessianImageFilter.h b/include/itkHessianImageFilter.h index 7f0f1f3..fd8953f 100644 --- a/include/itkHessianImageFilter.h +++ b/include/itkHessianImageFilter.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, @@ -46,7 +46,7 @@ template { public: - ITK_DISALLOW_COPY_AND_ASSIGN(HessianImageFilter); + ITK_DISALLOW_COPY_AND_MOVE(HessianImageFilter); /** Standard type alias */ using Self = HessianImageFilter; diff --git a/include/itkHessianImageFilter.hxx b/include/itkHessianImageFilter.hxx index 0d514b2..9a7e464 100644 --- a/include/itkHessianImageFilter.hxx +++ b/include/itkHessianImageFilter.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/include/itkMaskedAssignImageFilter.h b/include/itkMaskedAssignImageFilter.h new file mode 100644 index 0000000..e6c5668 --- /dev/null +++ b/include/itkMaskedAssignImageFilter.h @@ -0,0 +1,114 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * 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 + * + * 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, + * 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 itkMaskedAssignImageFilter_h +#define itkMaskedAssignImageFilter_h + +#include "itkTernaryGeneratorImageFilter.h" +#include "itkNumericTraits.h" + +namespace itk +{ + +/** + *\class MaskedAssignImageFilter + * \brief Assign values to a masked set of pixels. + * + * This class is templated over the types of the + * input image, the mask image and the type of the output image. + * Numeric conversions (castings) are done by the C++ defaults. + * + * The first input is the "input image", the second is the "mask image", + * the third is the "assign image". Any of the images can be set as constants, + * with third input can be set as constant with the `SetAssignConstant` method. + * + * For the "masked input" non-zero values are considered the mask, and assigned values + * from the "assign input". + * + * The following is the logic applied per pixel (pixel value or constant value) : + * + \code + if pixel_from_mask_image != 0 + pixel_output_image = pixel_assign_image + else + pixel_output_image = pixel_input_image + \endcode + * + * The pixel from the "input image" is cast to the pixel type of the output image. + * + * Note all images must be geometrically congruent. + * + * \sa MaskImageFilter + * \ingroup SimpleITKFilters + * + */ +template +class MaskedAssignImageFilter : public TernaryGeneratorImageFilter + +{ +public: + ITK_DISALLOW_COPY_AND_MOVE(MaskedAssignImageFilter); + + /** Standard class type aliases. */ + using Self = MaskedAssignImageFilter; + using Superclass = TernaryGeneratorImageFilter; + + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Runtime information support. */ + itkTypeMacro(MaskedAssignImageFilter, TernaryGeneratorImageFilter); + + /** Typedefs **/ + using InputImageType = TInputImage; + using MaskImageType = TMaskImage; + using AssignImageType = TOutputImage; + using OutputImageType = TOutputImage; + + using OutputPixelType = typename OutputImageType::PixelType; + + itkSetInputMacro(MaskImage, MaskImageType); + itkGetInputMacro(MaskImage, MaskImageType); + + itkSetInputMacro(AssignImage, AssignImageType); + itkGetInputMacro(AssignImage, AssignImageType); + + virtual void + SetAssignConstant(const OutputPixelType & v) + { + this->SetConstant3(v); + } + virtual OutputPixelType + GetAssignConstant() const + { + return this->GetConstant3(); + } + +protected: + MaskedAssignImageFilter(); + ~MaskedAssignImageFilter() override = default; +}; +} // end namespace itk + +#endif + +#ifndef ITK_MANUAL_INSTANTIATION +#include "itkMaskedAssignImageFilter.hxx" +#endif diff --git a/include/itkMaskedAssignImageFilter.hxx b/include/itkMaskedAssignImageFilter.hxx new file mode 100644 index 0000000..76b54b7 --- /dev/null +++ b/include/itkMaskedAssignImageFilter.hxx @@ -0,0 +1,49 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * 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 + * + * 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, + * 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 itkMaskedAssignImageFilter_hxx +#define itkMaskedAssignImageFilter_hxx + +#include "itkMaskedAssignImageFilter.h" + +namespace itk +{ +template +MaskedAssignImageFilter::MaskedAssignImageFilter() +{ + this->SetPrimaryInputName("InputImage"); + this->AddRequiredInputName("MaskImage", 1); + this->AddRequiredInputName("AssignImage", 2); + + auto func = [](const typename InputImageType::PixelType & input, + const typename MaskImageType::PixelType & mask, + const typename AssignImageType::PixelType & assign) -> OutputPixelType { + if (mask != NumericTraits::Zero) + { + return assign; + } + else + { + return static_cast(input); + } + }; + this->SetFunctor(func); +} + +} // end namespace itk + +#endif diff --git a/include/itkNPasteImageFilter.h b/include/itkNPasteImageFilter.h index c595069..2ef324c 100644 --- a/include/itkNPasteImageFilter.h +++ b/include/itkNPasteImageFilter.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, @@ -40,8 +40,8 @@ namespace itk * repositioned to DestinationIndex, then the output will just be * a copy of the input. * - * This filter supports running "InPlace" to efficiently reuses the destination image buffer for the output, removing the - * need to copy the destination pixels to the output. + * This filter supports running "InPlace" to efficiently reuses the destination image buffer for the output, removing + * the need to copy the destination pixels to the output. * * When the source image is a lower dimension than the destination image then the DestinationSkipAxes parameter * specifies which axes in the destination image are set to 1 when copying the region or filling with a constant. @@ -60,7 +60,7 @@ template { public: - ITK_DISALLOW_COPY_AND_ASSIGN(NPasteImageFilter); + ITK_DISALLOW_COPY_AND_MOVE(NPasteImageFilter); /** Standard class type aliases. */ using Self = NPasteImageFilter; diff --git a/include/itkNPasteImageFilter.hxx b/include/itkNPasteImageFilter.hxx index f60406a..56f0c85 100644 --- a/include/itkNPasteImageFilter.hxx +++ b/include/itkNPasteImageFilter.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, @@ -89,7 +89,7 @@ NPasteImageFilter::VerifyPreconditions( if (sourceInput == nullptr && constantInput == nullptr) { - itkExceptionMacro("The Source or the Constant input are required.") + itkExceptionMacro("The Source or the Constant input are required."); } @@ -285,7 +285,7 @@ NPasteImageFilter::GetPresumedDestinati if (numberSkippedAxis != (InputImageDimension - SourceImageDimension)) { - itkExceptionMacro("Number of skipped axis " << m_DestinationSkipAxes) + itkExceptionMacro("Number of skipped axis " << m_DestinationSkipAxes); } InputImageSizeType ret; diff --git a/include/itkObjectnessMeasureImageFilter.h b/include/itkObjectnessMeasureImageFilter.h index fde6665..0c635d7 100644 --- a/include/itkObjectnessMeasureImageFilter.h +++ b/include/itkObjectnessMeasureImageFilter.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, @@ -74,7 +74,7 @@ template class ObjectnessMeasureImageFilter : public ImageToImageFilter { public: - ITK_DISALLOW_COPY_AND_ASSIGN(ObjectnessMeasureImageFilter); + ITK_DISALLOW_COPY_AND_MOVE(ObjectnessMeasureImageFilter); /** Standard class type alias. */ using Self = ObjectnessMeasureImageFilter; diff --git a/include/itkObjectnessMeasureImageFilter.hxx b/include/itkObjectnessMeasureImageFilter.hxx index 59f9bf3..db0e302 100644 --- a/include/itkObjectnessMeasureImageFilter.hxx +++ b/include/itkObjectnessMeasureImageFilter.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/setup.py b/setup.py index 28cc2c1..fa0a4f4 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name='itk-simpleitkfilters', - version='0.1.0', + version='0.3.0', author='SimpleITK', author_email='itk+community@discourse.itk.org', packages=['itk'], @@ -44,6 +44,6 @@ keywords='ITK InsightToolkit', url=r'https://itk.org/', install_requires=[ - r'itk>=5.1.0.post2' + r'itk>=5.2.0' ] ) diff --git a/src/itkDICOMOrientation.cxx b/src/itkDICOMOrientation.cxx index 4f2f760..5d9edff 100644 --- a/src/itkDICOMOrientation.cxx +++ b/src/itkDICOMOrientation.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, @@ -55,12 +55,12 @@ const std::string & DICOMOrientation::GetAsString() const { const auto & codeToString = GetCodeToString(); - auto iter = codeToString.find(m_Value); + auto iter = codeToString.find(m_Value); if (iter != codeToString.end()) - { + { return iter->second; - } - assert( codeToString.find(OrientationEnum::INVALID) != codeToString.end()); + } + assert(codeToString.find(OrientationEnum::INVALID) != codeToString.end()); return codeToString.find(OrientationEnum::INVALID)->second; } @@ -170,31 +170,54 @@ DICOMOrientation::DirectionCosinesToOrientation(const DirectionType & dir) // but it is DIFFERENT in the meaning of direction in terms of sign-ness. CoordinateEnum terms[3] = { CoordinateEnum::UNKNOWN, CoordinateEnum::UNKNOWN, CoordinateEnum::UNKNOWN }; - for (unsigned i = 0; i < 3; i++) - { + std::multimap< double, std::pair > value_to_idx; + for (unsigned int c = 0; c < 3; ++c ) + { + for (unsigned int r = 0; r < 3; ++r ) + { + value_to_idx.emplace(std::abs(dir[c][r]), std::make_pair(c,r)); + } + } - const unsigned dominant_axis = Function::Max3(dir[0][i], dir[1][i], dir[2][i]); + for (unsigned i = 0; i < 3; ++i) + { + + auto max_idx = value_to_idx.rbegin()->second; + const unsigned int max_c = max_idx.first; + const unsigned int max_r = max_idx.second; - const int dominate_sgn = Math::sgn(dir[dominant_axis][i]); + const int max_sgn = Math::sgn(dir[max_c][max_r]); + + for (auto it = value_to_idx.begin(); it != value_to_idx.end();) + { + if (it->second.first == max_c || it->second.second == max_r) + { + value_to_idx.erase(it++); + } + else + { + ++it; + } + } - switch (dominant_axis) + switch (max_c) { case 0: { - // When the dominate axis sign is positive, assign the coordinate for the direction we are increasing towards. + // When the dominant axis sign is positive, assign the coordinate for the direction we are increasing towards. // ITK is in LPS, so that is the positive direction - terms[i] = (dominate_sgn == 1) ? CoordinateEnum::Left : CoordinateEnum::Right; + terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Left : CoordinateEnum::Right; break; } case 1: { - terms[i] = (dominate_sgn == 1) ? CoordinateEnum::Posterior : CoordinateEnum::Anterior; + terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Posterior : CoordinateEnum::Anterior; break; } case 2: { - terms[i] = (dominate_sgn == 1) ? CoordinateEnum::Superior : CoordinateEnum::Inferior; + terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Superior : CoordinateEnum::Inferior; break; } default: - itkGenericExceptionMacro("Unexpected Axis") + itkGenericExceptionMacro("Unexpected Axis"); } } diff --git a/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.md5 b/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.md5 deleted file mode 100644 index ae9d581..0000000 --- a/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.md5 +++ /dev/null @@ -1 +0,0 @@ -1fdb74a9029cf33147ace42e2d6c8f15 diff --git a/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.sha512 b/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.sha512 new file mode 100644 index 0000000..83f4b48 --- /dev/null +++ b/test/Baseline/ObjectnessMeasureImageFilterTest1.nii.sha512 @@ -0,0 +1 @@ +c6509e0f113026360dd0c2c4375f7442a693638912015eaaad2173896c1dfe3895aa0bef49e2809891ada7f1b2e9e1553f80898a3dd6754216c4b1f9ed5f5537 diff --git a/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.md5 b/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.md5 deleted file mode 100644 index 3eefacf..0000000 --- a/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.md5 +++ /dev/null @@ -1 +0,0 @@ -68046dd24c7824ef346d5a219e271d47 diff --git a/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.sha512 b/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.sha512 new file mode 100644 index 0000000..9f9c18a --- /dev/null +++ b/test/Baseline/ObjectnessMeasureImageFilterTest2.nii.sha512 @@ -0,0 +1 @@ +9266a2fc5216696f978ebc8437f242972a5300139f527f94034a3409a642c22b67e96c1b844c200b33038bdea35232841297238e4627598efb4108722d132eb2 diff --git a/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.md5 b/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.md5 deleted file mode 100644 index ce92a61..0000000 --- a/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.md5 +++ /dev/null @@ -1 +0,0 @@ -8cc0bc4f769074e53bd1379a730b8df5 diff --git a/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.sha512 b/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.sha512 new file mode 100644 index 0000000..1d353e1 --- /dev/null +++ b/test/Baseline/itkHessianToObjectnessMeasureImageFilterTest2.mha.sha512 @@ -0,0 +1 @@ +a411c8fa380caf20d0fb3ebe70cb11595267477b0e3837d086a41ee4f94be879a60e491ec532d6f83779e8d8ab6d904bcce5290952d73d9dd95edd2d63fb9fc1 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f42350a..49b08f0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,6 +61,7 @@ add_test(NAME itkHessianImageFilterTest set(SimpleITKFiltersGTest itkHessianImageFilterGTest.cxx - itkDICOMOrientImageFilterGTest.cxx) + itkDICOMOrientImageFilterGTest.cxx + itkMaskedAssignImageFilterGTest.cxx) CreateGoogleTestDriver(SimpleITKFilters "${SimpleITKFilters-Test_LIBRARIES}" "${SimpleITKFiltersGTest}") diff --git a/test/Input/DSA.png.md5 b/test/Input/DSA.png.md5 deleted file mode 100644 index 0223a95..0000000 --- a/test/Input/DSA.png.md5 +++ /dev/null @@ -1 +0,0 @@ -02e576585b1d28ad4d016129be2aa224 diff --git a/test/Input/DSA.png.sha512 b/test/Input/DSA.png.sha512 new file mode 100644 index 0000000..25cb160 --- /dev/null +++ b/test/Input/DSA.png.sha512 @@ -0,0 +1 @@ +9338a27235ef1b4fd41066c1c1d5cad4f88da444db58229b90cb4e72bac25cab47b574673e078b302b3ce5071bdb0a6d714b7c8144b7501dc0857380238b5b4d diff --git a/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.md5 b/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.md5 deleted file mode 100644 index 5c35811..0000000 --- a/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.md5 +++ /dev/null @@ -1 +0,0 @@ -40c95795843d6a036769786b154329e3 diff --git a/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.sha512 b/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.sha512 new file mode 100644 index 0000000..eb761c6 --- /dev/null +++ b/test/Input/itkHessianToObjectnessMeasureImageFilterTest.mha.sha512 @@ -0,0 +1 @@ +afe4a473bba3fd2e2672b7e0360b488136dab2d745c078a1025275a2dfe15d373ab0dc750f8597ff0d6925dbf4dfad43ec245c0c96a56aff25a616efd5a8ccdf diff --git a/test/itkDICOMOrientImageFilterGTest.cxx b/test/itkDICOMOrientImageFilterGTest.cxx index a0b7ffa..002cae0 100644 --- a/test/itkDICOMOrientImageFilterGTest.cxx +++ b/test/itkDICOMOrientImageFilterGTest.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, @@ -450,8 +450,15 @@ TEST(DICOMOrientation, DirectionCosinesToOrientation) d(1, 1) = 1; d(0, 2) = 1; EXPECT_EQ(OE::SPL, DICOMOrientation::DirectionCosinesToOrientation(d)); -} + const double data[] = {0.5986634407395047, 0.22716302314740483, -0.768113953548866, + 0.5627936241740271, 0.563067040943212, 0.6051601804419384, + 0.5699696670095713, -0.794576911518317, 0.20924175102261847}; + ImageType::DirectionType::InternalMatrixType m{data}; + d.GetVnlMatrix() = m; + EXPECT_EQ(OE::PIR, DICOMOrientation::DirectionCosinesToOrientation(d)); + +} TEST(DICOMOrientation, OrientationToDirectionCosines) { diff --git a/test/itkHessianImageFilterGTest.cxx b/test/itkHessianImageFilterGTest.cxx index 07f06c8..fca69d5 100644 --- a/test/itkHessianImageFilterGTest.cxx +++ b/test/itkHessianImageFilterGTest.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, @@ -154,16 +154,16 @@ TEST_F(HessianImageFilterFixture, ValueTest_3D) Utils::HessianImageType::Pointer output = filter->GetOutput(); - std::cout << "Value: " << image->GetPixel(MakeIndex(11, 12, 12)) << std::endl; - std::cout << "Value: " << image->GetPixel(MakeIndex(12, 12, 12)) << std::endl; - std::cout << "Value: " << image->GetPixel(MakeIndex(13, 12, 12)) << std::endl; - std::cout << "Value: " << image->GetPixel(MakeIndex(14, 12, 12)) << std::endl; + std::cout << "Value: " << image->GetPixel(itk::MakeIndex(11, 12, 12)) << std::endl; + std::cout << "Value: " << image->GetPixel(itk::MakeIndex(12, 12, 12)) << std::endl; + std::cout << "Value: " << image->GetPixel(itk::MakeIndex(13, 12, 12)) << std::endl; + std::cout << "Value: " << image->GetPixel(itk::MakeIndex(14, 12, 12)) << std::endl; ITK_EXPECT_VECTOR_NEAR( - MakeFixedArray(-0.0001615, 0.0, 0.0, -0.0001615, 0.0, -0.0001615), output->GetPixel(MakeIndex(12, 12, 12)), 1e-6); + MakeFixedArray(-0.0001615, 0.0, 0.0, -0.0001615, 0.0, -0.0001615), output->GetPixel(itk::MakeIndex(12, 12, 12)), 1e-6); ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-0.00014602, 0.0, 0.0, -0.00014602, 0.0, -0.00014602), - output->GetPixel(MakeIndex(10, 10, 10)), + output->GetPixel(itk::MakeIndex(10, 10, 10)), 1e-5); } @@ -179,7 +179,7 @@ TEST_F(HessianImageFilterFixture, ValueTest_2D) for (unsigned int i = 0; i < Utils::imageSize; ++i) { - image->SetPixel(MakeIndex(10, i), 1); + image->SetPixel(itk::MakeIndex(10, i), 1); } using Utils = FixtureUtilities<2>; @@ -190,16 +190,16 @@ TEST_F(HessianImageFilterFixture, ValueTest_2D) Utils::HessianImageType::Pointer output = filter->GetOutput(); - ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-2.0, 0.0, 0.0), output->GetPixel(MakeIndex(10, 10)), 1e-6); + ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-2.0, 0.0, 0.0), output->GetPixel(itk::MakeIndex(10, 10)), 1e-6); - ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-2.0, 0.0, 0.0), output->GetPixel(MakeIndex(10, 0)), 1e-6); + ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-2.0, 0.0, 0.0), output->GetPixel(itk::MakeIndex(10, 0)), 1e-6); - image->SetSpacing(MakeVector(10.0, 2.0)); + image->SetSpacing(itk::MakeVector(10.0, 2.0)); image->Modified(); filter->Update(); - ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-.02, 0.0, 0.0), output->GetPixel(MakeIndex(10, 10)), 1e-6); + ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-.02, 0.0, 0.0), output->GetPixel(itk::MakeIndex(10, 10)), 1e-6); - ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-.02, 0.0, 0.0), output->GetPixel(MakeIndex(10, 0)), 1e-6); + ITK_EXPECT_VECTOR_NEAR(MakeFixedArray(-.02, 0.0, 0.0), output->GetPixel(itk::MakeIndex(10, 0)), 1e-6); } diff --git a/test/itkHessianImageFilterTest.cxx b/test/itkHessianImageFilterTest.cxx index 61d84f8..ef89402 100644 --- a/test/itkHessianImageFilterTest.cxx +++ b/test/itkHessianImageFilterTest.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, diff --git a/test/itkMaskedAssignImageFilterGTest.cxx b/test/itkMaskedAssignImageFilterGTest.cxx new file mode 100644 index 0000000..51ee74a --- /dev/null +++ b/test/itkMaskedAssignImageFilterGTest.cxx @@ -0,0 +1,255 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * 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 + * + * 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, + * 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 "itkGTest.h" + +#include "itkMaskedAssignImageFilter.h" +#include "itkVectorImage.h" + +#include "itkTestDriverIncludeRequiredIOFactories.h" +#include "itkTestingHashImageFilter.h" + +namespace +{ +class MaskedAssignFixture : public ::testing::Test +{ +public: + MaskedAssignFixture() = default; + ~MaskedAssignFixture() override = default; + +protected: + void + SetUp() override + { + RegisterRequiredFactories(); + } + + template + static std::string + MD5Hash(const TImageType * image) + { + + using HashFilter = itk::Testing::HashImageFilter; + typename HashFilter::Pointer hasher = HashFilter::New(); + hasher->SetInput(image); + hasher->InPlaceOff(); + hasher->Update(); + return hasher->GetHash(); + } + + template + struct FixtureUtilities + { + static const unsigned int Dimension = TInputImage::ImageDimension; + + using PixelType = typename TInputImage::PixelType; + using OutputPixelType = PixelType; + using InputImageType = TInputImage; + using OutputImageType = TInputImage; + using RegionType = typename InputImageType::RegionType; + using SizeType = typename TInputImage::SizeType; + using IndexType = typename TInputImage::IndexType; + + + using MaskImageType = TMaskImage; + using MaskRegionType = typename MaskImageType::RegionType; + using MaskSizeType = typename MaskImageType::SizeType; + using MaskIndexType = typename MaskImageType::IndexType; + + using FilterType = itk::MaskedAssignImageFilter; + + // Create a black image or empty + template + static typename TImage::Pointer + CreateImageT(unsigned int size = 100) + { + typename TImage::Pointer image = TImage::New(); + + typename TImage::SizeType imageSize; + imageSize.Fill(size); + image->SetRegions(typename TImage::RegionType(imageSize)); + InitializeImage(image.GetPointer()); + + return image; + } + + template + static void + InitializeImage(itk::Image * image) + { + image->Allocate(); + image->FillBuffer(itk::NumericTraits::ZeroValue()); + } + + + template + static void + InitializeImage(itk::VectorImage * image) + { + constexpr unsigned int sz = 3; + image->SetNumberOfComponentsPerPixel(sz); + image->Allocate(); + itk::VariableLengthVector p{ sz }; + p.Fill(itk::NumericTraits::ZeroValue()); + image->FillBuffer(p); + } + + static constexpr auto CreateImage = CreateImageT; + static constexpr auto CreateMaskImage = CreateImageT; + }; +}; +} // namespace + + +TEST_F(MaskedAssignFixture, SetGetPrint) +{ + using Utils = FixtureUtilities>; + + auto filter = Utils::FilterType::New(); + + auto image = Utils::CreateImage(100); + + EXPECT_STREQ("MaskedAssignImageFilter", filter->GetNameOfClass()); + + EXPECT_NO_THROW(filter->SetInput(image)); + EXPECT_EQ(image, filter->GetInput()); + EXPECT_ANY_THROW(filter->GetConstant1()); + + image = Utils::CreateImage(100); + EXPECT_NO_THROW(filter->SetInput1(image)); + EXPECT_EQ(image, filter->GetInput()); + EXPECT_ANY_THROW(filter->GetConstant1()); + + EXPECT_NO_THROW(filter->SetConstant1(1)); + EXPECT_NO_THROW(filter->GetInput()); + EXPECT_EQ(1, filter->GetConstant1()); + + + image = Utils::CreateImage(100); + EXPECT_NO_THROW(filter->SetInput2(image)); + EXPECT_EQ(image, filter->GetMaskImage()); + EXPECT_ANY_THROW(filter->GetConstant2()); + + image = Utils::CreateImage(100); + EXPECT_NO_THROW(filter->SetMaskImage(image)); + EXPECT_EQ(image, filter->GetMaskImage()); + EXPECT_ANY_THROW(filter->GetConstant2()); + + EXPECT_NO_THROW(filter->SetConstant2(2)); + EXPECT_NO_THROW(filter->GetMaskImage()); + EXPECT_EQ(2, filter->GetConstant2()); + + + image = Utils::CreateImage(100); + EXPECT_NO_THROW(filter->SetInput3(image)); + EXPECT_EQ(image, filter->GetAssignImage()); + EXPECT_ANY_THROW(filter->GetConstant3()); + EXPECT_ANY_THROW(filter->GetAssignConstant()); + + image = Utils::CreateImage(100); + EXPECT_NO_THROW(filter->SetAssignImage(image)); + EXPECT_EQ(image, filter->GetAssignImage()); + EXPECT_ANY_THROW(filter->GetConstant3()); + EXPECT_ANY_THROW(filter->GetAssignConstant()); + + EXPECT_NO_THROW(filter->SetConstant3(3)); + EXPECT_NO_THROW(filter->GetMaskImage()); + EXPECT_EQ(3, filter->GetConstant3()); + + + EXPECT_NO_THROW(filter->SetAssignConstant(4)); + EXPECT_NO_THROW(filter->GetMaskImage()); + EXPECT_EQ(4, filter->GetConstant3()); + EXPECT_EQ(4, filter->GetAssignConstant()); +} + +TEST_F(MaskedAssignFixture, Test1) +{ + + using Utils = FixtureUtilities, itk::Image>; + + + auto image = Utils::CreateImage(100); + image->FillBuffer(99); + + auto mask = Utils::CreateMaskImage(100); + mask->FillBuffer(0); + + auto filter = Utils::FilterType::New(); + + EXPECT_NO_THROW(filter->SetAssignConstant(5)); + EXPECT_EQ(5, filter->GetAssignConstant()); + + mask->SetPixel({ { 0, 0 } }, 1); + + mask->SetPixel({ { 20, 21 } }, 1); + + filter->SetInput(image); + filter->SetMaskImage(mask); + + filter->Update(); + auto output = filter->GetOutput(); + + EXPECT_EQ(5, output->GetPixel({ { 0, 0 } })); + EXPECT_EQ(99, output->GetPixel({ { 0, 1 } })); + + EXPECT_EQ(99, output->GetPixel({ { 1, 1 } })); + + EXPECT_EQ(5, output->GetPixel({ { 20, 21 } })); + + EXPECT_EQ("b28618b5cccaa828028a29b44d88c728", MD5Hash(output)); +} + + +TEST_F(MaskedAssignFixture, VectorTest2) +{ + + using Utils = FixtureUtilities, itk::Image>; + + auto image = Utils::CreateImage(21); + Utils::PixelType p{ image->GetNumberOfComponentsPerPixel() }; + p.Fill(12); + image->FillBuffer(p); + + auto filter = Utils::FilterType::New(); + + Utils::PixelType c{ 3 }; + c.Fill(0); + EXPECT_NO_THROW(filter->SetAssignConstant(c)); + EXPECT_EQ(c, filter->GetAssignConstant()); + + + auto mask = Utils::CreateMaskImage(21); + mask->FillBuffer(0); + mask->SetPixel({ { 2, 2 } }, 1); + + mask->SetPixel({ { 3, 19 } }, 1); + + filter->SetInput(image); + filter->SetMaskImage(mask); + + filter->Update(); + auto output = filter->GetOutput(); + + EXPECT_EQ(p, output->GetPixel({ { 0, 0 } })); + EXPECT_EQ(c, output->GetPixel({ { 2, 2 } })); + EXPECT_EQ(c, output->GetPixel({ { 3, 19 } })); + + + EXPECT_EQ("f089464fcbec9429f409ee779788cca3", MD5Hash(output)); +} diff --git a/test/itkNPasteImageFilterGTest.cxx b/test/itkNPasteImageFilterGTest.cxx index e2f2ce6..85be9c2 100644 --- a/test/itkNPasteImageFilterGTest.cxx +++ b/test/itkNPasteImageFilterGTest.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, diff --git a/test/itkObjectnessMeasureImageFilterTest.cxx b/test/itkObjectnessMeasureImageFilterTest.cxx index f582f71..6925b48 100644 --- a/test/itkObjectnessMeasureImageFilterTest.cxx +++ b/test/itkObjectnessMeasureImageFilterTest.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,