Skip to content

Commit

Permalink
Merge branch 'release-5.4' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Dec 20, 2024
2 parents ff2a573 + ec8c20c commit f72d1c2
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ GenerateImageSource<TOutputImage>::GenerateOutputInformation()
outputPtr->SetSpacing(referenceImage->GetSpacing());
outputPtr->SetOrigin(referenceImage->GetOrigin());
outputPtr->SetDirection(referenceImage->GetDirection());
this->m_Direction = referenceImage->GetDirection();
this->m_StartIndex = referenceImage->GetLargestPossibleRegion().GetIndex();
this->m_Size = referenceImage->GetLargestPossibleRegion().GetSize();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreidpb356aruiokudkoxyo47ol4nyesw3hywpfd4dbvigbixmcebmwe
13 changes: 13 additions & 0 deletions Modules/Filtering/ImageSources/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(ITKImageSourcesTests
itkGaborImageSourceTest.cxx
itkGaussianImageSourceTest.cxx
itkGridImageSourceTest.cxx
itkGridImageSourceTest2.cxx
itkPhysicalPointImageSourceTest.cxx)

createtestdriver(ITKImageSources "${ITKImageSources-Test_LIBRARIES}" "${ITKImageSourcesTests}")
Expand Down Expand Up @@ -138,6 +139,18 @@ itk_add_test(
0
0
0)
itk_add_test(
NAME
itkGridImageSourceTest5
COMMAND
ITKImageSourcesTestDriver
--compare
DATA{Baseline/itkGridImageSourceTest5.mha}
${ITK_TEST_OUTPUT_DIR}/itkGridImageSourceTest5.mha
itkGridImageSourceTest2
DATA{${ITK_DATA_ROOT}/Input/cthead1.png}
${ITK_TEST_OUTPUT_DIR}/itkGridImageSourceTest5.mha
)
itk_add_test(
NAME
itkPhysicalPointImageSourceTest0
Expand Down
68 changes: 68 additions & 0 deletions Modules/Filtering/ImageSources/test/itkGridImageSourceTest2.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*=========================================================================
*
* 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 "itkGridImageSource.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkSimpleFilterWatcher.h"
#include "itkTestingMacros.h"


int
itkGridImageSourceTest2(int argc, char * argv[])
{
if (argc != 3)
{
std::cout << "Usage: " << itkNameOfTestExecutableMacro(argv)
<< " inputImage"
<< " outputImage" << std::endl;
return EXIT_FAILURE;
}
const char * inputImageFile = argv[1];
const char * outputImageFile = argv[2];


constexpr unsigned int ImageDimension = 3;
using PixelType = uint8_t;

using ImageType = itk::Image<PixelType, ImageDimension>;

// Instantiate the filter
using GridSourceType = itk::GridImageSource<ImageType>;
auto gridImage = GridSourceType::New();

ITK_EXERCISE_BASIC_OBJECT_METHODS(gridImage, GridImageSource, GenerateImageSource);

ImageType::Pointer inputImage = itk::ReadImage<ImageType>(inputImageFile);

gridImage->SetReferenceImage(inputImage);
gridImage->UseReferenceImageOn();

itk::SimpleFilterWatcher watcher(gridImage, "GridImageSource");

ITK_TRY_EXPECT_NO_EXCEPTION(gridImage->Update());

using WriterType = itk::ImageFileWriter<ImageType>;
auto writer = WriterType::New();
writer->SetFileName(outputImageFile);
writer->SetInput(gridImage->GetOutput());

ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());

std::cout << "Test finished" << std::endl;
return EXIT_SUCCESS;
}

0 comments on commit f72d1c2

Please sign in to comment.