[Insight-users] ITK Python Wrapping Example: ImageRegistration5.py

Luis Ibanez luis . ibanez at kitware . com
Fri, 29 Aug 2003 18:22:26 -0400


Hi  Charl

I agree with you in that it will be more logical to return 
itkFixedArray<double> for
spacing.

The  origin should probably be an itkPoint<double, N> instead of a 
simple double *.

However, this seems to be a pretty invasive change to be done at this 
point when
we are so close to the release 1.4.  Calls to Set/GetOrigin() and 
Set/GetSpacing()
are all over the place in the toolkit and in the applications.

Adding the Python example to the release seem to be a good idea. At this 
point
there is only one developer (Brad) with write access to the repository. 
 All the last
minute modifications are going through his validation.  


   Luis


--------------------------
Charl P. Botha wrote:

> Hua Qian wrote:
>
>>  47 fixedSpacing = fixedImage.GetSpacing()
>>  48 fixedOrigin = fixedImage.GetOrigin()
>>  49 fixedSize = fixedImage.GetLargestPossibleRegion().GetSize()
>>  50
>>  51 centerFixed = ( DArray_getitem( fixedOrigin, 0) +
>>                       DArray_getitem( fixedSpacing, 0) *
>>                       fixedSize.GetElement(0) / 2.0,
>>  52                 DArray_getitem( fixedOrigin, 1) +
>>                       DArray_getitem( fixedSpacing, 1) *
>>                       fixedSize.GetElement(1) / 2.0  )
>>
>> GetSpacing()/GetOrigin() returns a pointer to double,
>> while GetSize() return a reference to itkArray.
>> It seems that the only way to access the elements in
>> Spacing and Origin is to use DArray_getitem.
>> Is there any other way to do this?
>
>
> This is similar to the previous problem with the GetElement() method 
> of itk::Array.  To solve that, we simply removed the non-const C++ 
> version, as there was a SetElement() method in anycase.
>
> In this case, GetOrigin() and GetSpacing() explicitly return a pointer 
> to double (it has to, as the dimension can be N), which also results 
> in the swig wrapping returning a _p_double and necessitates the use of 
> DArray_getitem().
>
> I wonder if it wouldn't be more logical for GetOrigin()/GetSpacing() 
> to return itkArrays... it seems the mOrigin and mSpacing ivars of 
> itkImageBase are double arrays however.
>
> 1. Can any of the ITK olbies comment on this?
> 2. Is there a chance that this valuable example of Hua Qian's can make 
> it into the repository before the 1.4 release?
>
> Regards,
> Charl
>