[Insight-users] 2D deformable registration : Reading Vector Images

Luis Ibanez luis.ibanez at kitware.com
Wed Jun 9 13:24:54 EDT 2004


Hi Ping,

This bug has been fixed.

You should be able to read vector images now.


Regards,


    Luis


-------------------
ping chen wrote:

> Hi Luis, 
> 
> I want to know if we are able to read the deformation
> field vector image and use it to warp other images
> now?last time, we talk about reopen this bug, i wonder
> wether this bug is fixed or not? 
> 
> Thank you
> Ping 
>  
> 
> --- Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
>>Hi Ping,
>>
>>You are right, the Get() method is what
>>should be used to retrieve the pixel
>>values.
>>
>>It was my mistake to put (*it) in the
>>previous email.
>>
>>Sorry about that.
>>
>>---
>>
>>Your test shows that the reading
>>of vector images may still have some
>>problems. We may have to reopen that
>>bug in the database...
>>
>>
>>
>>    Luis
>>
>>
>>
>>----------------
>>ping chen wrote:
>>
>>
>>>hi Luis,
>>>
>>>
>>>i add your code in, but it runs into such errors, 
>>>
>>>Building dependencies cmake.check_depends...
>>>Building object file fieldreader.o...
>>>/Users/Ping/Desktop/field2/fieldreader.cxx: In
>>>function `int main(int, 
>>>   char**)':
>>>/Users/Ping/Desktop/field2/fieldreader.cxx:86:
>>
>>error:
>>
>>>no match for `* 
>>>  
>>
>>itk::ImageRegionIterator<DeformationFieldType>&'
>>
>>>operator
>>>
>>
> /Users/Ping/Insight/Utilities/vxl/core/vnl/vnl_transpose.h:69:
> 
>>>error: candidates
>>>   are: vnl_matrix<double> operator*(const
>>>vnl_matrix<double>&, const 
>>>   vnl_transpose&)
>>>/Users/Ping/Desktop/field2/fieldreader.cxx:87:
>>
>>error:
>>
>>>no match for `* 
>>>  
>>
>>itk::ImageRegionIterator<DeformationFieldType>&'
>>
>>>operator
>>>
>>
> /Users/Ping/Insight/Utilities/vxl/core/vnl/vnl_transpose.h:69:
> 
>>>error: candidates
>>>   are: vnl_matrix<double> operator*(const
>>>vnl_matrix<double>&, const 
>>>   vnl_transpose&)
>>>
>>>
>>>the error happens where we add 
>>>  const double x = fabs( (*it)[0] );
>>>  const double y = fabs( (*it)[1] );
>>>
>>>i dont know how to use iterator to get specific
>>
>>voxel
>>
>>>values but that doesnt matter, instead i just use
>>>it.Get( ) to get all the values and save in a
>>
>>logfile 
>>
>>>so below is the code i add to the original code
>>>
>>>DeformationFieldType::Pointer  fieldimage2=
>>>DeformationFieldType::New();
>>> fieldimage2 = fieldreader1->GetOutput();
>>>
>>>double maxx = 0;
>>>double maxy = 0;
>>>itk::ImageRegionIterator<
>>>           DeformationFieldType >  it(
>>
>>fieldimage2,
>>
>>>               fieldimage2->GetBufferedRegion() );
>>>
>>>it.GoToBegin();
>>>
>>>while( !it.IsAtEnd() )
>>>   {
>>>//   const double x = fabs( (*it)[0] );
>>> //  const double y = fabs( (*it)[1] );
>>>//   if( x > maxx ) maxx = x ;
>>>//   if( y > maxy ) maxy = y ;
>>>  std::cout << "vector values = " << it.Get( ) <<
>>>std::endl; 
>>>   ++it;
>>>   }
>>>
>>>std::cout << "Max fabs X = " << maxx << std::endl;
>>>std::cout << "Max fabs Y = " << maxy << std::endl;
>>>
>>>and run the program as 
>>>./fieldreader VectorDeformationField.mhd
>>>BrainProtonDensitySliceBorder20.png try.img >>
>>
>>logfile
>>
>>>when checking the logfile, we can see the vector
>>>vaules are all zeros. 
>>>
>>>
>>>vector values = [0, 0]
>>>vector values = [0, 0]
>>>vector values = [0, 0]
>>>vector values = [0, 0]
>>>vector values = [0, 0]
>>>vector values = [0, 0]
>>>
>>>
>>>Thanks,
>>>Ping 
>>>
>>>
>>>--- Luis Ibanez <luis.ibanez at kitware.com> wrote:
>>>
>>>
>>>>Hi Ping,
>>>>
>>>>Your code looks fine.
>>>>
>>>>
>>>>Note that you are applying a deformable
>>
>>registration
>>
>>>>methods to a pair of images that are only
>>
>>different
>>
>>>>in their translation.
>>>>
>>>>The ranges that you obtain from ParaView seems to
>>>>be ok with the expected translations: 13 in X and
>>
>>17
>>
>>>>in Y.
>>>>
>>>>Please try the following:
>>>>
>>>>After updating the reader of the deformation
>>
>>field,
>>
>>>>add a while loop and visit all the pixels in the
>>>>vector field, and compute the max abs value of
>>>>the components.
>>>>
>>>>The fact is that if you still are observing that
>>>>the warped image looks exactly the same as the
>>>>input image... that means that the vector field
>>>>is null... and there may be still some problem
>>>>when reading vector images.
>>>>
>>>>Your experiment with the while loop will help
>>>>to decide the question.
>>>>
>>>>The loop will look like
>>>>
>>>>double maxx = 0;
>>>>double maxy = 0;
>>>>itk::ImageRegionIterator<
>>>>          DeformationFieldType >  it( fieldimage,
>>>>              fieldimage->GetBufferedRegion() );
>>>>
>>>>it.GoToBegin();
>>>>
>>>>while( !it.IsAtEnd() )
>>>>  {
>>>>  const double x = fabs( (*it)[0] );
>>>>  const double y = fabs( (*it)[1] );
>>>>  if( x > maxx ) maxx = x ;
>>>>  if( y > maxy ) maxy = y ;
>>>>  ++it;
>>>>  }
>>>>
>>>>std::cout << "Max fabs X = " << maxx << std::endl;
>>>>std::cout << "Max fabs Y = " << maxy << std::endl;
>>>>
>>>>
>>>>
>>>>
>>>>Please let us know what you find.
>>>>
>>>>
>>>>   Thanks
>>>>
>>>>
>>>>
>>>>       Luis
>>>>
>>>>
>>>>
>>>>
>>>>-----------------
>>>>ping chen wrote:
>>>>
>>>>
>>>>
>>>>>Hi Luis,
>>
> === message truncated ===
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/ 
> 





More information about the Insight-users mailing list