-
Notifications
You must be signed in to change notification settings - Fork 9
BUG: Avoid copying uninitialized pixels in VectorIterationBenchmark #109
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
base: master
Are you sure you want to change the base?
Conversation
N-Dekker
commented
Dec 10, 2025
- Following ITK pull request BUG: Avoid copying uninitialized pixels in CastImageFilter ITK#5680
Following ITK pull request InsightSoftwareConsortium/ITK#5680 "BUG: Avoid copying uninitialized pixels in CastImageFilter"
| if constexpr (isVariableLengthVector<OutputPixelType>) | ||
| { | ||
| value[k] = static_cast<typename OutputPixelType::ValueType>(inputPixel[k]); | ||
| OutputPixelType value(outputIt.Get()); | ||
| for (unsigned int k = 0; k < componentsPerPixel; ++k) | ||
| { | ||
| value[k] = static_cast<typename OutputPixelType::ValueType>(inputPixel[k]); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| OutputPixelType value; | ||
| for (unsigned int k = 0; k < componentsPerPixel; ++k) | ||
| { | ||
| value[k] = static_cast<typename OutputPixelType::ValueType>(inputPixel[k]); | ||
| } | ||
| outputIt.Set(value); |
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.
Note that the VariableLengthVector case just calls outputIt.Get(), whereas the regular Vector/FixedArray case just calls outputIt.Set(value), with this PR!
thewtex
left a comment
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.
🔥
| OutputPixelType value(outputIt.Get()); | ||
| for (unsigned int k = 0; k < componentsPerPixel; ++k) | ||
|
|
||
| if constexpr (isVariableLengthVector<OutputPixelType>) |
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.
🐇
|
Thank you for applying the bug fix here too. I was hoping to see the performance difference with the change, compare to the the original loop. Please merge if you are done with this change. |