Skip to content

ENH: Add convenience function ReadImage#2184

Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Add-convenience-function-ReadImage
Dec 22, 2020
Merged

ENH: Add convenience function ReadImage#2184
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Add-convenience-function-ReadImage

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

Added itk::ReadImage<TOutputImage>(const std::string & filename), to
allows simplifying the C++ code for reading an image.

Suggested by Dženan Zukić (@dzenanz) at
#2102 (comment)

Follow-up to:
"ENH: add a convenience function WriteImage"
Pull request: #2160
Commit: 60b0984

Replaced manual creation of ImageFileReader objects in Common tests by
calls to the new itk::ReadImage function. Also removed related
redundant try-catch blocks from SymmetricSecondRankTensorImage tests.

@N-Dekker
Copy link
Copy Markdown
Contributor Author

Review suggestion: ignore white space when comparing the files: https://github.com/InsightSoftwareConsortium/ITK/pull/2184/files?w=1

@thewtex thewtex requested a review from dzenanz December 17, 2020 04:52
@N-Dekker N-Dekker marked this pull request as ready for review December 17, 2020 07:30
@hjmjohnson
Copy link
Copy Markdown
Member

Nice! LGTM, but I think @dzenanz should have a look before merging.

@N-Dekker
Copy link
Copy Markdown
Contributor Author

@hjmjohnson Thank you for your approval, Hans. An alternative could be to add the function as a staticmember function to ImageFileReader. In order to support a call like:

 auto image = itk::ImageFileReader<TOutputImage>::ReadImage(filename);

That would also be OK to me. But I think people prefer to just call itk::ReadImage<TOutputImage>(filename) 😃

@dzenanz dzenanz requested a review from blowekamp December 17, 2020 22:40
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Dec 17, 2020

@thewtex we should definitely mention these convenience functions in 5.2.0 release notes.

Copy link
Copy Markdown
Member

@blowekamp blowekamp left a comment

Choose a reason for hiding this comment

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

The behavior to the streaming test changes with this PR.

Comment thread Modules/Core/Common/test/itkStreamingImageFilterTest3.cxx Outdated
Comment thread Modules/IO/ImageBase/include/itkImageFileReader.h Outdated
@N-Dekker N-Dekker force-pushed the Add-convenience-function-ReadImage branch 2 times, most recently from e1a671a to 56f39bb Compare December 19, 2020 10:48
Added `itk::ReadImage<TOutputImage>(const std::string & filename)`, to
allows simplifying the C++ code for reading an image.

Suggested by Dženan Zukić at
InsightSoftwareConsortium#2102 (comment)

Follow-up to:
"ENH: add a convenience function WriteImage"
Pull request: InsightSoftwareConsortium#2160
Commit: 60b0984

Replaced manual creation of `ImageFileReader` objects in Common tests by
calls to the new `itk::ReadImage` function. Also removed related
redundant try-catch blocks from SymmetricSecondRankTensorImage tests.
@N-Dekker N-Dekker force-pushed the Add-convenience-function-ReadImage branch from 56f39bb to 3778f98 Compare December 19, 2020 10:56
@dzenanz dzenanz requested a review from blowekamp December 21, 2020 16:50
@dzenanz dzenanz dismissed blowekamp’s stale review December 21, 2020 16:51

Requested change has been addressed

@hjmjohnson hjmjohnson merged commit aeea88b into InsightSoftwareConsortium:master Dec 22, 2020
@dzenanz
Copy link
Copy Markdown
Member

dzenanz commented Dec 22, 2020

Do we need ITK_TEMPLATE_EXPORT in the declaration?

Good question @dzenanz but honestly I do not know. The function template is entirely implemented "header only" (implemented entiry in the .h file) so I thought an export macro wouldn't be necessary. What would the macro do?

N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Dec 22, 2020
Tests that an image written by `itk::WriteImage` can be read back,
without loss of data.

Uses two recently added functions:
 - `itk::ReadImage`: pull request InsightSoftwareConsortium#2184 commit aeea88b
 - `operator==` for images: pull request InsightSoftwareConsortium#2188 commit 7f3337d

(`operator==` is called internally by GoogleTest `EXPECT_EQ`.)
hjmjohnson pushed a commit that referenced this pull request Dec 22, 2020
Tests that an image written by `itk::WriteImage` can be read back,
without loss of data.

Uses two recently added functions:
 - `itk::ReadImage`: pull request #2184 commit aeea88b
 - `operator==` for images: pull request #2188 commit 7f3337d

(`operator==` is called internally by GoogleTest `EXPECT_EQ`.)
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 5, 2022
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#2184 commit InsightSoftwareConsortium/ITK@aeea88b "ENH: Add convenience function ReadImage", merged on on 22 December 2020, and included with ITK v5.2rc01.
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 5, 2022
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#2184 commit InsightSoftwareConsortium/ITK@aeea88b "ENH: Add convenience function ReadImage", merged on on 22 December 2020, and included with ITK v5.2rc01.
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 5, 2022
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#2184 commit InsightSoftwareConsortium/ITK@aeea88b "ENH: Add convenience function ReadImage", merged on on 22 December 2020, and included with ITK v5.2rc01.
N-Dekker added a commit to N-Dekker/ITKSphinxExamples that referenced this pull request May 16, 2022
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#2184
commit InsightSoftwareConsortium/ITK@aeea88b
"ENH: Add convenience function ReadImage", merged on 22 December 2020, and
included with ITK v5.2rc01
dzenanz pushed a commit to InsightSoftwareConsortium/ITKSphinxExamples that referenced this pull request May 17, 2022
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#2184
commit InsightSoftwareConsortium/ITK@aeea88b
"ENH: Add convenience function ReadImage", merged on 22 December 2020, and
included with ITK v5.2rc01
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