Skip to content

ENH: support multiple labels in ContourExtractor2DImageFilter - #2323

Merged
thewtex merged 1 commit into
InsightSoftwareConsortium:masterfrom
Leengit:multilabel_in_itkContourExtractor2DImageFilter
Mar 1, 2021
Merged

ENH: support multiple labels in ContourExtractor2DImageFilter#2323
thewtex merged 1 commit into
InsightSoftwareConsortium:masterfrom
Leengit:multilabel_in_itkContourExtractor2DImageFilter

Conversation

@Leengit

@Leengit Leengit commented Feb 16, 2021

Copy link
Copy Markdown
Contributor

The previously existing function of ContourExtractor2DImageFilter is to trace the contour between regions of a 2-dimensional image defined by values that are higher and lower, respectively, than a specified contour value. To that we add a LabelContoursOn() option; when set then every distinct value in the 2-dimensional image defines its own region, and boundaries for all such regions are generated.

At present this is WIP. Please review for the API changes. The implementation works, but is not performant; it needs additional work.

PR Checklist

  • No API changes were made (or the changes have been approved)
  • No major design changes were made (or the changes have been approved)
  • Added test (or behavior not changed)
  • Updated API documentation (or API not changed)
  • Added license to new files (if any)
  • Added Python wrapping to new files (if any) as described in ITK Software Guide Section 9.5
  • Added ITK examples for all new major features (if any)

@thewtex
thewtex requested review from N-Dekker and dzenanz February 16, 2021 16:24
@Leengit

Leengit commented Feb 17, 2021

Copy link
Copy Markdown
Contributor Author

I force-pushed with performance improvements. It could be even better, but this is plenty good enough. I will change this Pull Request to non-draft once it has passed its GitHub checks.

@Leengit
Leengit marked this pull request as ready for review February 18, 2021 13:26
@Leengit

Leengit commented Feb 18, 2021

Copy link
Copy Markdown
Contributor Author

A next step for performance improvement could be to address the bounding box calculation for each label. Do we have something like skimage.measure.regionprops functionality, which computes bounding boxes for multiple labels all at once, in ITK? If yes, a future pull request could have this code make use of that. If not, a future pull request could add the regionprops functionality to ITK .

@Leengit

Leengit commented Feb 18, 2021

Copy link
Copy Markdown
Contributor Author

This pull request adds a new ValuesAreLabels option to itkContourExtractor2DImageFilter. Is there an API document somewhere where that should be documented ... or are the Doxygen comment blocks within itkContourExtractor2DImageFilter.h sufficient?

@dzenanz

dzenanz commented Feb 18, 2021

Copy link
Copy Markdown
Member

Doxygen blocks are sufficient, as the documentation is generated from them.

@thewtex thewtex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ValuesAreLabels -> LabelContours

Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.h Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.h
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx Outdated
Comment thread Modules/Filtering/Path/test/itkContourExtractor2DImageFilterTest.cxx Outdated
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx

@thewtex thewtex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx
Comment thread Modules/Filtering/Path/include/itkContourExtractor2DImageFilter.hxx
@Leengit

Leengit commented Mar 1, 2021

Copy link
Copy Markdown
Contributor Author

I just rebased to the current master branch and squashed the commits. This is ready for a final sanity check and merge.

@Leengit
Leengit requested review from N-Dekker and thewtex March 1, 2021 14:58
@N-Dekker

N-Dekker commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

The implementation works, but is not performant

@Leengit Do you think the performance is good enough now? Just curious. 😃

I wonder if it would be possible/useful to make the iteration over the labels for (InputPixelType label : allLabels) the inner loop, instead of the outer loop. Do you think that could affect the performance in a good way?

Anyway I don't have concrete plans to use the filter right now (sorry), I'm just trying to help a little bit!

@Leengit

Leengit commented Mar 1, 2021

Copy link
Copy Markdown
Contributor Author

Timings for the algorithm are now good, about 17x speed compared to the initial implementation, and beating the competitors such as HistomicsTK. The loop over labels as an inner loop is a good idea ... it would involve having separate lists of contours for each label being built up in parallel. We are going to go with the parallel constructions, but using a multi-threaded approach: issue #2343, which @dzenanz has assigned to himself, and is awaiting the merging of this PR.

@N-Dekker writes:

Anyway I don't have concrete plans to use the filter right now (sorry), I'm just trying to help a little bit!

Very much appreciated!

@thewtex
thewtex merged commit 6b38169 into InsightSoftwareConsortium:master Mar 1, 2021
@Leengit
Leengit deleted the multilabel_in_itkContourExtractor2DImageFilter branch March 1, 2021 19:35
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…abel_in_itkContourExtractor2DImageFilter
hjmjohnson pushed a commit to hjmjohnson/ITK that referenced this pull request May 12, 2026
…abel_in_itkContourExtractor2DImageFilter
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