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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkImageAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ ImageAlgorithm::ReferenceCopy(const InputImageType * inIma
return;
}

ImageRegionConstIterator it(inImage, inRegion);
ImageRegionIterator ot(outImage, outRegion);
ImageRegionConstIterator<InputImageType> it(inImage, inRegion);
ImageRegionIterator<OutputImageType> ot(outImage, outRegion);

while (!it.IsAtEnd())
{
Expand Down
4 changes: 4 additions & 0 deletions Modules/Filtering/RLEImage/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ set(

createtestdriver( RLEImage "${RLEImage-Test_LIBRARIES}" "${RLEImageTests}" )

set(RLEImageGTests itkRLEImageAlgorithmCopyGTest.cxx)

creategoogletestdriver(RLEImage "${RLEImage-Test_LIBRARIES}" "${RLEImageGTests}")

add_executable(
runFromIDE
manualTest.cxx
Expand Down
84 changes: 84 additions & 0 deletions Modules/Filtering/RLEImage/test/itkRLEImageAlgorithmCopyGTest.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*=========================================================================
*
* 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 "itkImageAlgorithm.h"
#include "itkRLEImage.h"

#include <gtest/gtest.h>

// Locks in correct iterator deduction in ImageAlgorithm::Copy when the
// source or destination is a partially-specialized Image-like template.
namespace
{
constexpr unsigned int Dimension = 3;
using PixelType = short;
using RLEType = itk::RLEImage<PixelType, Dimension>;
using ImageType = itk::Image<PixelType, Dimension>;

RLEType::RegionType
MakeRegion()
{
RLEType::SizeType size = { { 4, 4, 4 } };
RLEType::IndexType start = { { 0, 0, 0 } };
return RLEType::RegionType{ start, size };
}
} // namespace

TEST(RLEImageAlgorithmCopy, FromRLEToImage)
{
const auto region = MakeRegion();

auto rle = RLEType::New();
rle->SetRegions(region);
rle->Allocate();
rle->FillBuffer(7);

auto dst = ImageType::New();
dst->SetRegions(region);
dst->Allocate();
dst->FillBuffer(0);

itk::ImageAlgorithm::Copy<RLEType, ImageType>(rle.GetPointer(), dst.GetPointer(), region, region);

for (itk::ImageRegionConstIterator<ImageType> it(dst, region); !it.IsAtEnd(); ++it)
{
ASSERT_EQ(it.Get(), 7) << "Mismatch at " << it.GetIndex();
}
}

TEST(RLEImageAlgorithmCopy, FromImageToRLE)
{
const auto region = MakeRegion();

auto src = ImageType::New();
src->SetRegions(region);
src->Allocate();
src->FillBuffer(11);

auto rleDst = RLEType::New();
rleDst->SetRegions(region);
rleDst->Allocate();
rleDst->FillBuffer(0);

itk::ImageAlgorithm::Copy<ImageType, RLEType>(src.GetPointer(), rleDst.GetPointer(), region, region);

for (itk::ImageRegionConstIterator<RLEType> it(rleDst, region); !it.IsAtEnd(); ++it)
{
ASSERT_EQ(it.Get(), 11) << "Mismatch at " << it.GetIndex();
}
}
2 changes: 1 addition & 1 deletion Modules/IO/VTK/test/itkVTIImageIOReadWriteTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ itkVTIImageIOReadWriteTest(int argc, char * argv[])
reader->SetFileName(inputImage);
ITK_TRY_EXPECT_NO_EXCEPTION(reader->UpdateOutputInformation());

auto imageIO = reader->GetImageIO();
auto imageIO = reader->GetModifiableImageIO();
imageIO->SetFileName(inputImage);

ITK_TRY_EXPECT_NO_EXCEPTION(imageIO->ReadImageInformation());
Expand Down
Loading