Use the faster TransformPhysicalPointToIndex overload#2873
Conversation
dzenanz
left a comment
There was a problem hiding this comment.
The second is more of a style commit, than a performance one. Potentially split most of it into a separate style commit. Only calls inside large for loops (per pixel) count as real performance improvement!
| IndexType centerIndex; | ||
|
|
||
| outputImage->TransformPhysicalPointToIndex(center, centerIndex); | ||
| IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center); |
There was a problem hiding this comment.
I am not sure how important performance is here, and other similar instances. But this improves style slightly, and saves a line of code.
@dzenanz I agree, it's mostly a style commit, it just might improve the performance. 😄 The first commit might improve the performance of user code, as it is part of a filter. Actually I was trying out the C++17 [[nodiscard]] attribute on the older (potentially slower) overload, Will adjust the commit message of the second commit, from PERF to STYLE. |
Replaced `image->TransformPhysicalPointToIndex(point, index)` call by `image->TransformPhysicalPointToIndex(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. Follow-up to pull request InsightSoftwareConsortium#993 commit 0703516 "STYLE: Use image->TransformPhysicalPointToIndex(point), returning index"
Replaced `image->TransformPhysicalPointToIndex(point, index)` calls by `image->TransformPhysicalPointToIndex(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. This is mostly a style improvement. It is recommended to only use the slightly slower overload, `TransformPhysicalPointToIndex(point, index)` when its `bool` return value is to be used. Follow-up to pull request InsightSoftwareConsortium#993 commit 0703516 "STYLE: Use image->TransformPhysicalPointToIndex(point), returning index"
d8d8473 to
919a3a6
Compare
|
I think this pull request is ready now, only CircleCi has failed, saying "Build timed out", and:
|
Replaced image->TransformPhysicalPointToContinuousIndex(point, index) calls by image->TransformPhysicalPointToContinuousIndex<T>(point), which is slightly faster, as it does not figure out whether or not the point is inside the image. Follow-up to pull request InsightSoftwareConsortium#2873 commit eb6ac88 "PERF: Use the faster TransformPhysicalPointToIndex overload in filter"
Replaced `image->TransformPhysicalPointToContinuousIndex(point, index)` calls by `image->TransformPhysicalPointToContinuousIndex<T>(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. Follow-up to pull request InsightSoftwareConsortium#2873 commit eb6ac88 "PERF: Use the faster TransformPhysicalPointToIndex overload in filter"
Replaced `image->TransformPhysicalPointToContinuousIndex(point, index)` calls by `image->TransformPhysicalPointToContinuousIndex<T>(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. Declared variables that are initialized by `image->TransformPhysicalPointToContinuousIndex<T>(point)` `const`, when possible. Follow-up to pull request InsightSoftwareConsortium#2873 commit eb6ac88 "PERF: Use the faster TransformPhysicalPointToIndex overload in filter"
Replaced `image->TransformPhysicalPointToContinuousIndex(point, index)` calls by `image->TransformPhysicalPointToContinuousIndex<T>(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. Declared variables that are initialized by `image->TransformPhysicalPointToContinuousIndex<T>(point)` `const`, when possible. Follow-up to pull request #2873 commit eb6ac88 "PERF: Use the faster TransformPhysicalPointToIndex overload in filter"
Adjusted its `GPUGenerateData()` member function to call the faster `TransformPhysicalPointToIndex` overload.
Addresses MSVC compiler warnings saying:
itkGPUShrinkImageFilter.hxx(109,39): warning C4834: discarding return value of function with [[nodiscard]] attribute
Similar to pull request InsightSoftwareConsortium/ITK#2873 commit InsightSoftwareConsortium/ITK@eb6ac88 "Use the faster `TransformPhysicalPointToIndex` overload in filter", November 16, 2021.
Adjusted its `GPUGenerateData()` member function to call the faster `TransformPhysicalPointToIndex` overload.
Addresses MSVC compiler warnings saying:
itkGPUShrinkImageFilter.hxx(109,39): warning C4834: discarding return value of function with [[nodiscard]] attribute
Similar to pull request InsightSoftwareConsortium/ITK#2873 commit InsightSoftwareConsortium/ITK@eb6ac88 "Use the faster `TransformPhysicalPointToIndex` overload in filter", November 16, 2021.
Replaced `image->TransformPhysicalPointToContinuousIndex(point, index)` calls by `image->TransformPhysicalPointToContinuousIndex<T>(point)`, which is slightly faster, as it does not figure out whether or not the point is inside the image. Declared variables that are initialized by `image->TransformPhysicalPointToContinuousIndex<T>(point)` `const`, when possible. Follow-up to pull request InsightSoftwareConsortium#2873 commit 264b885 "PERF: Use the faster TransformPhysicalPointToIndex overload in filter"
Replaced
image->TransformPhysicalPointToIndex(point, index)calls byimage->TransformPhysicalPointToIndex(point), which is slightly faster,as it does not figure out whether or not the point is inside the image.
Follow-up to pull request #993
commit 0703516
"STYLE: Use image->TransformPhysicalPointToIndex(point), returning index"