ITKSphinxExamples icon indicating copy to clipboard operation
ITKSphinxExamples copied to clipboard

Watershed with Distancemap Example

Open kmader opened this issue 7 years ago • 5 comments

Watershed with distance maps are useful for segmenting lungs, foams, and other cellular materials. I have a Kaggle Kernel that does it with ITK but it would be nice to have pure ITK demos with associated C++ and Python implementations image

kmader avatar Mar 25 '18 17:03 kmader

@kmader This is awesome.

I'd be glad to help in adding these to the existing examples. I grant that we are missing a CONTRIBUTING.md file, but you can get some inspiration from the ITK and ITKSoftwareGuide contributing processes.

Please, let me know when you experience difficulties.

jhlegarreta avatar Mar 27 '18 20:03 jhlegarreta

@kmader @thewtex I started having a look at this.

A few comments:

  • @kmader you said you also had the C++ code: could you please share it? I do not find it in kaggle.
  • I assume that the skimage library used for morphological operations can be done in ITK, as well as the mesh part.
  • I assume that instead of showing the images, we will be writing them to disk, the showing in the Documentation.rst file.
  • I assume that we can do the analysis of the bubble features in a side file that uses pandas or matplotlib as required so that the example does not add additional third-party dependencies. I think it's cleaner. Let me know what you think.
  • To avoid an excessively large vertical scroll, I'd write to files the screenshots from pandas or matplotlib visualizations of three image arrangements as in the original notebook, and these would be the files included in the Documentation.rst file.

Thanks.

jhlegarreta avatar Oct 28 '18 00:10 jhlegarreta

After taking some time to think about this, I think an solution is to split the notebook code in three pieces:

  • One taking the input image and providing the distance map, watershed and clean segmentation outputs, which will be the usual Code.py file.
  • One taking the outputs of the segmentation and displaying and saving screenshots of the process with subplots, as in the kaggle example by Kevin.
  • One taking the . csv file and performing the comparative analysis.

This will ideally enable separating non-ITK dependencies and providing a clean code.

Will work on it and will contribute with a version as time allows.

jhlegarreta avatar Oct 28 '18 18:10 jhlegarreta

As I am working on this, I have a comment about the code in the kaggle notebook: although there is a section that is aimed at removing small bubbles, I'd say that these are not effectively removed, since in cell 10 the cleaned_img variable in line

cleaned_img = binary_opening(old_img, ball(3))

is local to the loop and never gets used. So I'd say that the loop is just doing a re-labelling, right? @kmader may be there is some cell missing?

jhlegarreta avatar Nov 04 '18 18:11 jhlegarreta

Good catch, that looks like a bug!

On Sun, Nov 4, 2018, 20:44 Jon Haitz Legarreta Gorroño < [email protected] wrote:

As I am working on this, I have a comment about the code in the kaggle notebook: although there is a section that is aimed at removing small bubbles, I'd say that these are not effectively removed, since the cell 10 line

cleaned_img = binary_opening(old_img, ball(3))

cleaned_img is local to the loop and never gets used. So I'd say that the loop is just doing a re-labelling, right? @kmader https://github.com/kmader may be there is some cell missing?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/InsightSoftwareConsortium/ITKExamples/issues/48#issuecomment-435694948, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHFmI1CcI9Rz1LKU58LxphC91SGB8C8ks5urzWggaJpZM4S6OEh .

kmader avatar Nov 04 '18 18:11 kmader