Skip to content
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

ENH: Convenience overloads for ImageBase Transform member functions #868

Merged
merged 1 commit into from
May 16, 2019
Merged

ENH: Convenience overloads for ImageBase Transform member functions #868

merged 1 commit into from
May 16, 2019

Conversation

N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented May 14, 2019

Added convenience overloads to the six ImageBase Transform member
functions, returning the result by value, instead of having an output
parameter:

TransformPhysicalPointToIndex
TransformPhysicalPointToContinuousIndex
TransformContinuousIndexToPhysicalPoint
TransformIndexToPhysicalPoint
TransformLocalVectorToPhysicalVector
TransformPhysicalVectorToLocalVector

These overloads allow users to have a more "functional" programming
style, or at least, place the transformation result in a const variable.

So instead of:

Bar bar;
image->TransformFooToBar(foo, bar);

It typically allows users to write:

const auto bar = image->TransformFooToBar(foo);

Added a unit test to itkImageBaseGTest

@dzenanz
Copy link
Member

dzenanz commented May 14, 2019

I have been annoyed by absence of these more than once!

* Floating point index results are rounded to integers
* Returns true if the resulting index is within the image, false otherwise
Copy link
Member

Choose a reason for hiding this comment

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

Minor changes request to documentation. I think it is worth explicitly noting that these functions do not verify that the resulting indices fall within the image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hjmjohnson Please check the added note:

* \note This specific overload does not figure out whether or not

* \note This specific overload does not figure out whether or not
(copied from the previous note, but adapted code snippets)

Copy link
Member

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

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

+100 I too have desired these convenience methods for some time.

I have a minor comment change request.

@N-Dekker
Copy link
Contributor Author

Update: Still preparing an amend that should address the comment by @hjmjohnson and add at least a very little unit test. Hopefully tomorrow... :-)

@hjmjohnson
Copy link
Member

I approve the wording of the commit message.

@N-Dekker
Copy link
Contributor Author

N-Dekker commented May 15, 2019

The GTest that I added compiles well on ITK.Windows, but it fails on macOS and Linux, because I should have added a template keyword on various places. For example:

imageBase.TransformPhysicalPointToContinuousIndex<float>(PointType())

Should be:

imageBase.template TransformPhysicalPointToContinuousIndex<float>(PointType())

At line

imageBase.TransformPhysicalPointToContinuousIndex<float>(PointType()),

I'll try to fix it (tomorrow).

Added convenience overloads to the six `ImageBase` Transform member
functions, returning the result by value, instead of having an output
parameter:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint
    TransformLocalVectorToPhysicalVector
    TransformPhysicalVectorToLocalVector

These overloads allow users to have a more "functional" programming
style, or at least, place the transformation result in a `const` variable.

So instead of:

    Bar bar;
    image->TransformFooToBar(foo, bar);

It typically allows users to write:

    const auto bar = image->TransformFooToBar(foo);

Added a unit test to itkImageBaseGTest.
@N-Dekker
Copy link
Contributor Author

I think this pull request is OK now. CDash appears stuck "in progress" for no reason. It has succeeded at Linux, Windows and macOS. :-)

@dzenanz dzenanz merged commit 65233e3 into InsightSoftwareConsortium:master May 16, 2019
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 4, 2021
Added `TransformPhysicalPointToIndex(point)` and
`TransformPhysicalPointToContinuousIndex(point)` overloads to
`PhasedArray3DSpecialCoordinatesImage`, which return the index,
instead of a `bool`.

Follow-up to:
pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 4, 2021
Added convenience overloads of four Transform member functions of
`PhasedArray3DSpecialCoordinatesImage`, returning the result by value,
instead of having an output parameter:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Follow-up to:
pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
dzenanz pushed a commit that referenced this pull request Apr 6, 2021
Added convenience overloads of four Transform member functions of
`PhasedArray3DSpecialCoordinatesImage`, returning the result by value,
instead of having an output parameter:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Follow-up to:
pull request #868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 20, 2021
Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 20, 2021
Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 20, 2021
Added the five missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0.

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 20, 2021
Added the five missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0.

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 21, 2021
Added the five missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0.

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 21, 2021
Added the four missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 21, 2021
Added the four missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"

And pull request InsightSoftwareConsortium#1207
commit 55f8ac2
"BUG: Missing ImageAdapter function signatures"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 21, 2021
Added the four missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"

And pull request InsightSoftwareConsortium#1207
commit 55f8ac2
"BUG: Missing ImageAdapter function signatures"
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Nov 21, 2021
Added the four missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Included a GoogleTest unit test.

Follow-up to pull request InsightSoftwareConsortium#868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"

And pull request InsightSoftwareConsortium#1207
commit 55f8ac2
"BUG: Missing ImageAdapter function signatures"
dzenanz pushed a commit that referenced this pull request Nov 23, 2021
Added the four missing single parameter overloads of point/index/vector
conversion member functions to `ImageAdaptor`, which were already there
for `ImageBase` with ITK version 5.0:

    TransformPhysicalPointToIndex
    TransformPhysicalPointToContinuousIndex
    TransformContinuousIndexToPhysicalPoint
    TransformIndexToPhysicalPoint

Included a GoogleTest unit test.

Follow-up to pull request #868
commit 65233e3
"ENH: Convenience overloads for ImageBase Transform member functions"

And pull request #1207
commit 55f8ac2
"BUG: Missing ImageAdapter function signatures"
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request Feb 4, 2022
Return-by-value is easier to read than pass-by-non-const-reference, and `ContinuousIndexType` has lightweight copy semantics, so it appears preferable for `AdvancedBSplineDeformableTransformBase::TransformPointToContinuousGridIndex` to simply return the continuous index.

Declared local continuous index variables `const`.

Analogous to ITK pull request InsightSoftwareConsortium/ITK#868 commit InsightSoftwareConsortium/ITK@65233e3 "ENH: Convenience overloads for ImageBase Transform member functions"
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request Feb 5, 2022
Return-by-value is easier to read than pass-by-non-const-reference, and `ContinuousIndexType` has lightweight copy semantics, so it appears preferable for `AdvancedBSplineDeformableTransformBase::TransformPointToContinuousGridIndex` to simply return the continuous index.

Declared local continuous index variables `const`.

Analogous to ITK pull request InsightSoftwareConsortium/ITK#868 commit InsightSoftwareConsortium/ITK@65233e3 "ENH: Convenience overloads for ImageBase Transform member functions"
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.

None yet

3 participants