[Insight-users] Transformation in ModelToImageRegistration example

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Apr 18 09:39:52 EDT 2006


That is what I noticed too, but it's is the more minor point. What I  
think is the larger potential error in the code is the direction and  
the order of the transformations does not make since (at least not to  
me).  This example is also a special case, because the transformation  
which this registration should converge to is the identity. This  
results in a correct answer even if the registration transformation  
is applied in the wrong direction.

I was looking at this code to write my own ImageToSpatialObjectMetric  
class. Even though I am unsure of the correct transformations I have  
gone ahead and written what I believe is the correct order of  
transformations. This is what I have:


    typedef itk::ImageRegionConstIteratorWithIndex<TFixedImage>  
myIteratorType;

    myIteratorType it(this->m_FixedImage,this->m_FixedImage- 
 >GetBufferedRegion());

    while(!it.IsAtEnd())
         {
           index[0] = it.GetIndex()[0];
           index[1] = it.GetIndex()[1];
           this->m_FixedImage->TransformIndexToPhysicalPoint(index,  
fixedPhysicalPoint);
           transformedPoint = this->m_Transform->TransformPoint 
(fixedPhysicalPoint);
           if (this->m_MovingSpatialObject->IsInside(transformedPoint, 
999)) {
        .....


 From my understanding this should be the correct order of  
transformations for this type of registration; is it?

Thanks,
Brad


On Apr 17, 2006, at 6:34 PM, Karthik Krishnan wrote:

> Looks like a bug to me too.
>
> The example seems to swap index and physical points and won't work  
> for images with spacing not equal to 1. (for instance if you say  
> imageFilter->SetSpacing(..)) and it seems to swap the notion of  
> Fixed and moving image.

> Bradley Lowekamp wrote:
>
>> Hello all,
>>
>> I am confused by the transformations going on in the example  
>> ModelToImageRegistration.cxx with regards to the custom Metric.  
>> Here are some highlights of the code:
>>
>> In SetMovingSpacialObject():
>>       ...
>>       typedef itk::ImageRegionConstIteratorWithIndex<TFixedImage>  
>> myIteratorType;
>>       myIteratorType it(this->m_FixedImage,this->m_FixedImage- 
>> >GetBufferedRegion());
>>       itk::Point<double,2> point;
>>       while(!it.IsAtEnd())
>>         {
>>         for(unsigned int i=0;i<Self::ObjectDimension;i++)
>>           {
>>           point[i]=it.GetIndex()[i];
>>           }
>>
>>         if(this->m_MovingSpatialObject->IsInside(point,99999))
>>           {
>>           m_PointList.push_back(point);
>>           }
>>         ++it;
>> ....
>> In GetValue():
>>        ...
>>        PointListType::const_iterator it = m_PointList.begin();
>>        ...
>>        while(it != m_PointList.end())
>>         {
>>         PointType transformedPoint = this->m_Transform- 
>> >TransformPoint(*it);
>>         this->m_FixedImage->TransformPhysicalPointToIndex 
>> (transformedPoint,index);
>>         ...
>>
>> I have been reading and rereading the relevant sections in the ITK  
>> software guide book, especially the "Direction of the Transform  
>> Mapping". I believe I understand the usage and direction of the  
>> transformations is the registration process. Perhaps this is a  
>> poor example, which takes some short cuts. But this is my  
>> understanding of this code:
>>
>> The created m_PointList contains a points in "image grid" space.  
>> (Slightly ambiguous as to which since the two are already aligned).
>>
>> Then the m_Transform is applied. This transform maps points from  
>> physical space of the fixed image to the physical space of the  
>> moving model according to the definition of said transform. (We  
>> can overlook the lack of image grid to physical space  
>> transformation since it is the identity in both cases.) So  
>> "transformedPoint" ought to be in the physical space of the moving  
>> model.
>>
>> Last the fixed image's physical to image grid index transform is  
>> applied. So "transformedPoint" must be in fixed image's physical  
>> space.
>>
>> So this is a contradiction, and I am confused. What am I missing  
>> here?
>>
>> Sorry for the repost. I am hoping that this one doesn't get  
>> hijacked too :)
>>
>> Thanks,
>> Brad
>>
>>
>>
>> ========================================================
>>
>> Bradley Lowekamp
>> Management Systems Designers Contractor for
>>
>> Office of High Performance Computing and Communications
>>
>> National Library of Medicine
>> blowekamp at mail.nih.gov <mailto:blowekamp at mail.nih.gov>
>>
>>
>> --------------------------------------------------------------------- 
>> ---
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>


More information about the Insight-users mailing list