[ITK] image segmentation

Giuseppe Amatulli giuseppe.amatulli at gmail.com
Tue Feb 14 16:11:17 EST 2017


Hi,
thanks for the input.
I try to follow your suggestion to build up a watershed segmentation image
starting from external markers, but i get something strange.

These are the files that i used

wget  https://dl.dropboxusercontent.com/u/29337496/small_core.tif
wget  https://dl.dropboxusercontent.com/u/29337496/cost_Int32.tif

python

import SimpleITK as sitk

img  = sitk.ReadImage("cost_Int32.tif")
core = sitk.ReadImage("small_core.tif")

feature_img = sitk.GradientMagnitude(img)
marker_img = sitk.ConnectedComponent(core, fullyConnected=False)

ws = sitk.MorphologicalWatershedFromMarkers(feature_img, marker_img,
markWatershedLine=True, fullyConnected=False)

sitk.WriteImage(ws,  'watershed.jpg' )


Moreover, I also try to save the final image as tiff, but i get the
following error.

sitk.WriteImage(ws,  'watershed.tif' )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/SimpleITK/SimpleITK.py",
line 7942, in WriteImage
    return _SimpleITK.WriteImage(*args)
RuntimeError: Exception thrown in SimpleITK WriteImage:
/tmp/SimpleITK-build/ITK/Modules/IO/TIFF/src/itkTIFFImageIO.cxx:544:
itk::ERROR: TIFFImageIO(0x2e6d880): TIFF supports unsigned/signed char,
unsigned/signed short, and float

seams to me the tiff is not supported or i miss some modules of ITK

May anyone help me

Thank you
Best
Giuseppe





On 13 February 2017 at 16:15, Francois Budin <francois.budin at kitware.com>
wrote:

> Hello Giuseppe,
>
> Yes it is possible to create this type of segmentation with ITK.
> The first step would be to convert your RGB(A) image into a grayscale
> image using RGBToLuminanceImageFilter [1]. The second step would be to run
> a watershed filter such as MorphologicalWatershedImageFilter [2]. If you
> want to keep the lines, use "MarkWatershedLineOn()".
>
> Hope this helps,
> Francois
>
> [1] https://itk.org/Doxygen/html/classitk_1_1RGBToLuminanceImageFilter.
> html
> [2] https://itk.org/Doxygen/html/classitk_1_1MorphologicalWatershedImageFi
> lter.html
>
> On Mon, Feb 13, 2017 at 3:56 PM, Giuseppe Amatulli <
> giuseppe.amatulli at gmail.com> wrote:
>
>>
>> Hi,
>> I'm new in ITK <https://itk.org/> and would like to have some
>> directions/suggestions.
>>
>> I'm trying to segment the image in Figure 1 and be able to identify
>> "valleys" between each one of the blue point.  In other words I
>> would like to obtain a red-line on the valleys like the one show in Figure
>> 2.
>>
>> Is this possible with ITK and if yes which are the commands/libraries
>> that should use?
>> Is there any python-itk example that I can use to obtain something
>> similar.
>>
>> Thanks
>> Best Giuseppe
>>
>>
>> FIGURE 1
>> [image: Inline images 2]
>>
>> FIGURE 2
>>
>> [image: Inline images 1]
>>
>>
>>
>> --
>> Giuseppe Amatulli, Ph.D.
>>
>> Research scientist at
>> Yale School of Forestry & Environmental Studies
>> Yale Center for Research Computing
>> Center for Science and Social Science Information
>> New Haven, 06511
>> Teaching: http://spatial-ecology.org
>> Work:  https://environment.yale.edu/profile/giuseppe-amatulli/
>>
>> _______________________________________________
>> Community mailing list
>> Community at itk.org
>> http://public.kitware.com/mailman/listinfo/community
>>
>>
>


-- 
Giuseppe Amatulli, Ph.D.

Research scientist at
Yale School of Forestry & Environmental Studies
Yale Center for Research Computing
Center for Science and Social Science Information
New Haven, 06511
Teaching: http://spatial-ecology.org
Work:  https://environment.yale.edu/profile/giuseppe-amatulli/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170214/e96c4468/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 114561 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20170214/e96c4468/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 49430 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/community/attachments/20170214/e96c4468/attachment-0003.png>


More information about the Community mailing list