ENH: Replace ExtractImageFilter with zero-copy sub-region extraction - #973
Open
axel-grc wants to merge 1 commit into
Open
ENH: Replace ExtractImageFilter with zero-copy sub-region extraction#973axel-grc wants to merge 1 commit into
axel-grc wants to merge 1 commit into
Conversation
Collaborator
Author
|
I made some tests on FDK, the extract phase is at least 1000x faster, but it is still a very small part of the total reconstruction time (<1%). |
axel-grc
force-pushed
the
SubRegion
branch
3 times, most recently
from
July 21, 2026 11:59
f6972b5 to
6f747a5
Compare
SimonRit
requested changes
Jul 23, 2026
SimonRit
left a comment
Collaborator
There was a problem hiding this comment.
I don't think this works. The proposed solution only works if the extracted region corresponds to a contiguous memory region of the input. This is not always the case and there is a check missing for this. If it is not contiguous, there should be a fallback to itk::ExtractImageFilter.
SimonRit
reviewed
Jul 23, 2026
Comment on lines
+108
to
+118
| #ifdef RTK_USE_CUDA | ||
| using TCudaImage = itk::CudaImage<PixelType, Dimension>; | ||
| if (TCudaImage * cudaOutput = dynamic_cast<TCudaImage *>(output.GetPointer())) | ||
| { | ||
| cudaOutput->GetModifiableDataManager()->SetBufferSize(numPixels * sizeof(PixelType)); | ||
| cudaOutput->GetModifiableDataManager()->SetImagePointer(cudaOutput); | ||
| cudaOutput->GetModifiableDataManager()->SetCPUBufferPointer(const_cast<PixelType *>(bufferPtr)); | ||
| cudaOutput->GetModifiableDataManager()->SetGPUDirtyFlag(true); | ||
| cudaOutput->GetModifiableDataManager()->SetCPUDirtyFlag(false); | ||
| } | ||
| #endif |
Collaborator
There was a problem hiding this comment.
I don't think CudaImage needs a specific case when dealing with CPU memory
When region is contiguous, replace itk::ExtractImageFilter with a lightweight free function that creates sub-region views by sharing the input buffer via SetImportPointer, avoiding pixel copies and filter pipeline overhead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #91 : Replace itk::ExtractImageFilter with a lightweight free function that creates sub-region views by sharing the input buffer via SetImportPointer, avoiding pixel copies and filter pipeline overhead.