[Insight-users] Example of ITK

Cagatay Bilgin bilgincc at gmail.com
Thu May 10 14:31:13 EDT 2012


Try casting your image to float type before
you feed to the smoother. That should do it
I guess.

Cagatay

On Thu, May 10, 2012 at 11:27 AM, Ing. Arturo Vargas Olivares <
ing.arturo.vargas at gmail.com> wrote:

> Hello to all !!
>
> I have implemented this code in order to test an example from the ITK
> software guide.
>
> import numpy as np
> import scipy.io as ios
> import matplotlib.pyplot as mplot
> import matplotlib.cm as cm
> import SimpleITK as sitk
> import sys
> #
> # Read the image
> #
> reader = sitk.ImageFileReader()
> reader.SetFileName( 'BrainProtonDensitySlice.png' )
> image = reader.Execute();
> #
> # Set up the writer
> #
> writer = sitk.ImageFileWriter()
> writer.SetFileName( 'BrainProtonDensitySlice_out.png' )
> #
> # Blur using CurvatureFlowImageFilter
> #
> blurFilter = sitk.CurvatureFlowImageFilter()
> blurFilter.SetNumberOfIterations( 5 )
> blurFilter.SetTimeStep( 0.125 )
> image = blurFilter.Execute( image )
> #
> # Set up ConnectedImageFilter for segmentation
> #
> segmentationFilter = sitk.ConnectedThresholdImageFilter()
> segmentationFilter.SetLower(150)
> segmentationFilter.SetUpper(180)
> segmentationFilter.SetReplaceValue(255)
> segmentationFilter.SetSeed((60,116))
> image = segmentationFilter.Execute( image )
> writer.Execute( image )
>
>
> It seems that everything is OK except the execution of my filters (see
> below). It says that the Pixel Type is the problem but I don't know how to
> fix this.
>
> Guys, do you have any ideas?
>
> ---------------------------------------------------------------------------
> RuntimeError                              Traceback (most recent call last)
> C:\Users\Student3\Desktop\MRI images\test8.py in <module>()
>      22 blurFilter.SetNumberOfIterations( 5 )
>      23 blurFilter.SetTimeStep( 0.125 )
> ---> 24 image = blurFilter.Execute( image )
>      25 #
>      26 # Set up ConnectedImageFilter for segmentation
>
> C:\Python27\lib\site-packages\simpleitk-0.4.0-py2.7-win-amd64.egg\SimpleITK.pyc
> in Execute(self, *args)
>    8050
>    8051         """
> -> 8052         return _SimpleITK.CurvatureFlowImageFilter_Execute(self,
> *args)
>    8053
>    8054     __swig_destroy__ = _SimpleITK.delete_CurvatureFlowImageFilter
> RuntimeError: Exception thrown in SimpleITK
> CurvatureFlowImageFilter_Execute: c:\users\bradley
> lowekamp\documents\source\simpleitk\code\common\include\sitkMemberFunctionFactory.txx:174:
> sitk::ERROR: Pixel type: vector of 8-bit unsigned integer is not supported
> in 2D byclass itk::simple::CurvatureFlowImageFilter
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120510/1dcdde89/attachment.htm>


More information about the Insight-users mailing list