-
-
Notifications
You must be signed in to change notification settings - Fork 723
PERF: Use region iterator image ComposeBigVectorImageFilter #5306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
| itk::ImageRegionConstIterator<VectorImageType> it(img, sliceRegion); | ||
| for (it.GoToBegin(); !it.IsAtEnd(); ++it) | ||
|
Comment on lines
+72
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @blowekamp Cool. 👍 Some small suggestions...
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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If possible, I would avoid calling if (const auto channelValue = it.Get()[i]; channelValue != i % 250)
{
++values[channelValue];
} |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
zshould always just have the same value asi(the current channel number), I would suggest removing the variablez, and usingidirectly:sliceRegion.SetIndex(2, i);