Replace buffered region iteration with FillBuffer in FastMarching filters#5970
Conversation
| } | ||
|
|
||
| // set all gradient vectors to zero | ||
| if (m_GenerateGradientImage) |
There was a problem hiding this comment.
This pull request would also merge the two consecutive if (m_GenerateGradientImage) statements:
Following the principle behind Include What You Use.
Replaced two manual iterations over buffered regions that just set all elements to the same value with equivalent (but more efficient) FillBuffer calls. Removed an unnecessary local `outputPixel` variable.
Replaced manual iterations over buffered regions by both FastMarchingUpwindGradientImageFilter and FastMarchingUpwindGradientImageFilterBase, that set all elements to a gradient of zero with equivalent (more efficient) FillBuffer calls.
6a491cb to
a85ada9
Compare
|
/azp run ITK.Linux |
Greptile SummaryThis PR simplifies initialization logic in three FastMarching filter implementation files by replacing verbose manual Key changes:
The Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[FastMarchingImageFilter::Initialize] --> B[output->Allocate]
B --> C["output->FillBuffer(m_LargeValue)\n(was: ImageRegionIterator loop)"]
C --> D["m_LabelImage->FillBuffer(LabelEnum::FarPoint)\n(was: ImageRegionIterator loop)"]
D --> E[Process AlivePoints / OutsidePoints / TrialPoints]
F[FastMarchingUpwindGradientImageFilter::Initialize] --> G[Superclass::Initialize]
G --> C
F --> H{m_GenerateGradientImage?}
H -- Yes --> I[m_GradientImage->Allocate]
I --> J["m_GradientImage->FillBuffer(GradientPixelType{})\n(was: ImageRegionIterator loop)"]
H -- No --> K[Skip]
L[FastMarchingUpwindGradientImageFilterBase::InitializeOutput] --> M[Superclass::InitializeOutput]
M --> N["oImage->FillBuffer(m_LargeValue)"]
L --> O[GradientImage->Allocate]
O --> P["GradientImage->FillBuffer(GradientPixelType{})\n(was: while loop)"]
Last reviewed commit: "PERF: Use FillBuffer..." |
| // set all output value to infinity | ||
| using OutputIterator = ImageRegionIterator<LevelSetImageType>; | ||
|
|
||
| PixelType outputPixel = m_LargeValue; |
There was a problem hiding this comment.
greptile-apps says at #5970 (comment)
Three unnecessary
outputPixeltemporary variables are also eliminated.
But it's really just one variable! So AI is inaccurate (or maybe I should say incorrect) this time.
Removed manual iterations over buffered regions that just set all elements to the same value, in FastMarching filters. Added equivalent (but more efficient) calls to
FillBuffer.