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

Charl P. Botha c . p . botha at ewi . tudelft . nl
Fri, 29 Aug 2003 21:23:57 +0100


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

-- 
charl p. botha http://cpbotha . net/ http://visualisation . tudelft . nl/