Skip to content

ENH: Lambda functions instead of functor classes in JosephForwardProjectionFilter#694

Open
MichaelColonel wants to merge 2 commits into
RTKConsortium:mainfrom
MichaelColonel:lambdas2
Open

ENH: Lambda functions instead of functor classes in JosephForwardProjectionFilter#694
MichaelColonel wants to merge 2 commits into
RTKConsortium:mainfrom
MichaelColonel:lambdas2

Conversation

@MichaelColonel

Copy link
Copy Markdown

Implementation of lambdas instead of functor classes in rtkJosephForwardProjectionFilter.
Test example of MIP filter using this new class.

Possible solution of issue #645.

@SimonRit

Copy link
Copy Markdown
Collaborator

Thanks a lot for doing this. Could you please modify the existing projector instead of creating a new one? That would facilitate the review and this is what we want eventually.
This is a big change so it will take time before we all agree on this...

@MichaelColonel

Copy link
Copy Markdown
Author

Could you please modify the existing projector instead of creating a new one? That would facilitate the review and this is what we want eventually.

I will do that, but what to do with JosephForwardAttenuatedProjectionImageFilter class?
There are some private members within functors classes, which can't be implemented in lambda functions.

@MichaelColonel

Copy link
Copy Markdown
Author

I've modified existing classes for JosephForwardProjectionFilter.
Not so sure about JosephForwardAttenuatedProjectionImageFilter though, in any case this PR is ready for a review.

@MichaelColonel MichaelColonel changed the title WIP: lambdas instead of functors in rtkJosephForwardProjectionFilter ENH: Lambda functions instead of functor classes in JosephForwardProjectionFilter Mar 4, 2025

@arobert01 arobert01 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the great work! It looks really good to me. I made some comments, mostly related to style.
Regarding JosephAttenuatedForwardProjector, based on the tests I did, everything seems to work well, and I don’t see a better way to do it. Maybe @SimonRit will have additional comments before merging.
If there are no further comments, we can also implement these changes in the Joseph-based back projectors.
Thanks again!

Comment on lines +70 to +71
*
* \author Simon Rit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the author part of the comments.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

using InputPixelType = typename TInputImage::PixelType;
using OutputPixelType = typename TOutputImage::PixelType;
using CoordinateType = double;
using WeightCoordinateType = typename itk::PixelTraits<InputPixelType>::ValueType;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WeightCoordinateType doesn't seem to be used in this case

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be removed.


std::cout << "\n\n****** Compare two resulted images ******" << std::endl;
CheckImageQuality<OutputImageType>(jfp->GetOutput(), mipfp->GetOutput(), 0.001, 0.000001, 1.E+19);
std::cout << "\n\nImages are OK! " << std::endl;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I would keep the same "Test PASSED! " sentence for consistency ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix that.

/** \brief Function to multiply the interpolation weights with the projected
* volume values and attenuation map.
*
* \author Antoine Robert

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove author section in the comments

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@SimonRit

Copy link
Copy Markdown
Collaborator

Thank you for your excellent contribution @MichaelColonel and your review @arobert01. This is very interesting work but I will include it in the next RTK major release. I am currently working on a minor release and will merge this one afterwards. Note that #629 will probably require additional work for this PR but I'll handle it.

@axel-grc

Copy link
Copy Markdown
Collaborator

I rebased to main and added a commit to do the same for JosephBackProjectionFilter

@axel-grc axel-grc requested a review from SimonRit April 22, 2026 14:54

@SimonRit SimonRit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axel-grc Can you please:

  • fix the wrapping (keep existing wrapping without functors)
  • remove the threadId parameter in the Backprojection as this is not multithreaded
  • squash the three commits of @MichaelColonel in one commit
    ?

@arobert01

Copy link
Copy Markdown
Collaborator

@axel-grc Can you please:

  • fix the wrapping (keep existing wrapping without functors)
  • remove the threadId parameter in the Backprojection as this is not multithreaded
  • squash the three commits of @MichaelColonel in one commit
    ?

@axel-grc Have you had a chance to start working on this yet? I'm currently working on a development based on this PR, so I'd be happy to step in and implement @SimonRit's requested changes if that helps.

@axel-grc

Copy link
Copy Markdown
Collaborator

@axel-grc Can you please:

  • fix the wrapping (keep existing wrapping without functors)
  • remove the threadId parameter in the Backprojection as this is not multithreaded
  • squash the three commits of @MichaelColonel in one commit
    ?

@axel-grc Have you had a chance to start working on this yet? I'm currently working on a development based on this PR, so I'd be happy to step in and implement @SimonRit's requested changes if that helps.

@arobert01 I did not start working on this yet.
I think you can take it from here, it would be great to test it in a real usecase.
Thanks !

Mikhail Polkovnikov and others added 2 commits May 27, 2026 14:31
…ardProjectionFilter

Lambdas were added to the classes:
  JosephForwardProjectionImageFilter,
  JosephForwardAttenuatedProjectionImageFilter,
  MaximumIntensityProjectionImageFilter.

Python wrappers for classes above have been modified.

Similar lambda functions can be added to back projection classes.
@arobert01

Copy link
Copy Markdown
Collaborator

@axel-grc Can you please:

  • fix the wrapping (keep existing wrapping without functors)
  • remove the threadId parameter in the Backprojection as this is not multithreaded
  • squash the three commits of @MichaelColonel in one commit
    ?

I implemented the requested changes and rebased to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants