[Insight-users] Example of ITK

Ing. Arturo Vargas Olivares ing.arturo.vargas at gmail.com
Thu May 10 15:28:14 EDT 2012


Hello again.

I tried the command but I still have problems, it says it is not supported
(see below).


image = sitk.Cast( image, sitk.sitkFloat32 )
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (7489, 0))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
C:\Users\Student3\Desktop\MRI images\<ipython-input-165-9a6139d5ca18> in
<module>()
----> 1 image = sitk.Cast( image, sitk.sitkFloat32 )
C:\Python27\lib\site-packages\simpleitk-0.4.0-py2.7-win-amd64.egg\SimpleITK.pyc
in Cast(*args, **kwargs)
   3597 def Cast(*args, **kwargs):
   3598   """Cast(Image image, PixelIDValueType pixelID) -> Image"""
-> 3599   return _SimpleITK.Cast(*args, **kwargs)
   3600 class Version(_object):
   3601     """Proxy of C++ itk::simple::Version class"""
RuntimeError: Exception thrown in SimpleITK Cast: C:\Users\Bradley
Lowekamp\Documents\Source\SimpleITK\Code\BasicFilters\src\sitkCastImageFilter.cxx:75:
sitk::ERROR: Filter does not support casting from casting vector of 8-bit
unsigned integer to 32-bit float

On Thu, May 10, 2012 at 3:13 PM, Cagatay Bilgin <bilgincc at gmail.com> wrote:

> Hi Arturo,
>
> the following line should cast the image to float
> image = sitk.Cast( image, sitk.sitkFloat32 )
>
> Let us know how it goes
>
> Cagatay
>
> On Thu, May 10, 2012 at 11:36 AM, Ing. Arturo Vargas Olivares <
> ing.arturo.vargas at gmail.com> wrote:
>
>> I'm new in this...
>> how do I cast my image to float?
>>
>>
>>
>> On Thu, May 10, 2012 at 2:31 PM, Cagatay Bilgin <bilgincc at gmail.com>wrote:
>>
>>> 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/afd98c90/attachment.htm>


More information about the Insight-users mailing list