[Insight-users] ITK Python Wrapping Examples

Hua Qian hqian at imaging . robarts . ca
Tue, 29 Jul 2003 14:06:55 -0400


Hi Luis,

Following up my previous post, my rebuilding for the python
wrapping went out okay and am trying out more examples.

I have a question about the ImageRegistration3.py example.
When I ran the example:

 > python ImageRegistration3.py 
../Data/BrainProtonDensitySliceBorder20.png 
../Data/BrainProtonDensitySliceShifted13x17y.png test1.png

I got following print out

<C itkRegularStepGradientDescentOptimizer_Pointer instance at 
_50605e08_p_itk__SmartPointerTitk__RegularStepGradientDescentOptimizer_t>
Starting registration
Final Registration Parameters
Translation X =  _28db2909_p_double
Translation Y =  _30db2909_p_double
Traceback (most recent call last):
  File "ImageRegistration3.py_1.2", line 104, in ?
    resampler = itkResampleImageFilterF2_New()
NameError: name 'itkResampleImageFilterF2_New' is not defined

After I modified the code a bit (see the diff below),
it generates correct output image. But the Translation X and
Translation Y parameters are still printed as:

Final Registration Parameters
Translation X =  _90db2909_p_double
Translation Y =  _98db2909_p_double

Is there anyway to print out the parameters in plain numbers?

Regards,

Hua


##################################################################
Index: ImageRegistration3.py
===================================================================
RCS file: 
/cvsroot/Insight/Insight/Examples/Registration/ImageRegistration3.py,v
retrieving revision 1.2
diff -r1.2 ImageRegistration3.py
104,105c104,105
< resampler = itkResampleImageFilterF2_New()
< resampler.SetTransform( transform    )
---
 > resampler = itkResampleImageFilterF2F2_New()
 > resampler.SetTransform( transform.GetPointer()    )
115a116,122
 > #
 > # Cast for output
 > #
 > outputCast = itkRescaleIntensityImageFilterF2US2_New()
 > outputCast.SetInput( resampler.GetOutput() )
 > outputCast.SetOutputMinimum( 0 )
 > outputCast.SetOutputMaximum( 65535 )
120c127
< writer = itkImageFileWriterF2_New()
---
 > writer = itkImageFileWriterUS2_New()
123c130
< writer.SetInput( resampler.GetOutput() )
---
 > writer.SetInput( outputCast.GetOutput() )




Luis Ibanez wrote:

>
> Hi Hua,
>
>
> I just rebulid the wrapping in a Linux Debian with gcc 3.3
> and both python examples are working ok.
>
> Note that the finite difference solver in ITK has been
> under revision in recent days. It may be that your CVS
> checkout took the CurvatureFlowImageFilter in an unstable
> state.
>
> You may want to update your CVS checkout (verify first
> if the dashboard is green, since we anticipate a lot
> of activity before August 1).
>
> In any case, Charl's observation is correct. ITK is throwing
> an exception that is not being catched. That's why the
> "abort" message appears.
>
> One possible reason for this exception being thrown is that
> the time step parameter provided to the filter is too big.
>
> The timeStep parameter that you are using for the
> CurvatureFlowImageFilter is right in the limit of the
> value accepted as the bound for producing numerically
> stable results.  Before updating your CVS, you may want
> to try with smaller values of time step. (e.g. 0.1 instead
> of 0.125).
>
>
>
> Please let us  know if you continue experincing any
> problems,
>
>
> Thanks
>
>
>
>   Luis
>
>
>
> -------------------
> Hua Qian wrote:
>
>> Hi,
>>
>> I am trying out the Python Wrapping for ITK recently. The build
>> went on every smoothly. But I had troubles running some of the
>> python examples. Some examples works, some don't.
>> For example, CurvatureAnisotropicDiffusionImageFilter.py ran
>> without problem:
>>
>>  > python CurvatureAnisotropicDiffusionImageFilter.py 
>> ../Data/BrainProtonDensitySlice.png test.png 10 0.125 3.0
>>
>> But CurvatureFlowImageFilter.py aborted abnormally:
>>  > python CurvatureFlowImageFilter.py 
>> ../Data/BrainProtonDensitySlice.png test.png 10 0.125
>> Abort
>>
>> Am I doing something wrong? I am using Mandrake Linux 9.1, gcc 3.2.2, 
>> python 2.2.2, cvs ITK, cvs CMake.
>>
>> Thanks,
>>
>> Hua Qian
>>
>>
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk . org
>> http://www . itk . org/mailman/listinfo/insight-users
>>
>
>