Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,23 @@ itkComposeBigVectorImageFilterTest(int, char *[])
VectorImageType::Pointer img = composeFilter->GetOutput();
std::cout << "Compose filter executed." << std::endl;


itk::ImageRegion<3> sliceRegion = img->GetLargestPossibleRegion();
sliceRegion.SetSize(2, 1); // Set the size of the z-dimension to 1

for (unsigned int i = 0; i < nchannels; ++i)
{
itk::IndexValueType z = i;
std::map<unsigned int, unsigned int> values;

for (itk::IndexValueType y = 0; y < size; ++y)
sliceRegion.SetIndex(2, z); // Set the index of the z-dimension to the current slice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If z should always just have the same value as i (the current channel number), I would suggest removing the variable z, and using i directly:

    sliceRegion.SetIndex(2, i);


itk::ImageRegionConstIterator<VectorImageType> it(img, sliceRegion);
for (it.GoToBegin(); !it.IsAtEnd(); ++it)
Comment on lines +72 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blowekamp Cool. 👍 Some small suggestions...

it.GoToBegin() is not necessary. An ImageRegionConstIterator always starts at the begin. So these two lines could be replaced with one:

    for (itk::ImageRegionConstIterator<VectorImageType> it(img, sliceRegion); !it.IsAtEnd(); ++it)

{
for (itk::IndexValueType x = 0; x < size; ++x)
if (it.Get()[i] != i % 250)
{
itk::Index<3> idx = { { x, y, z } };

auto pixel = img->GetPixel(idx);
if (pixel[i] != i % 250)
{
++values[pixel[i]];
}
++values[it.Get()[i]];
Comment on lines +75 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I would avoid calling it.Get()[i] twice. Instead, would it also work as follows?

    if (const auto channelValue = it.Get()[i]; channelValue != i % 250)
    {
      ++values[channelValue];
    }

}
}

Expand Down