[Insight-users] MultiResolution registration
Luis Ibanez
luis . ibanez at kitware . com
Sat, 25 Oct 2003 17:20:42 -0400
Hi Jesse,
If you want to save the matrix parameters in a file,
simply open the ifstream for the file and push the
matrix through the stream.
Something like:
std::ifstream myFile("outputmatrix.txt");
myFile << m_Transform->GetMatrix() << std::endl;
myFile.close();
Regards.
Luis
-----------------------
iajesse wrote:
> Hi Luis,
>
> I can understand the meaning of the final parameter, but I want to save
> the nine parameter in Overall transform matrix as a text file, for
> example "result.txt" ,I think it should be modified within following
> codes, but how to do it ?
>
> std::cout << "Overall transform matrix: " << std::endl;
> std::cout << m_Transform->GetMatrix() << std::endl;
> std::cout << "Overall transform offset: " << std::endl;
> std::cout << m_Transform->GetOffset() << std::endl;
>
>
> /**************************
> * Generating output
> **************************/
> std::cout << "Generating output ... " << std::endl;
>
>
> Thanks
>
> Jesse
>
> */Luis Ibanez <luis . ibanez at kitware . com>/* wrote:
>
>
> Hi Jesse,
>
> Please look at the examples in the SoftwareGuide
>
> http://www . itk . org/ItkSoftwareGuide . pdf
>
> Chapter 8, pdf-page 241, paper-page 215.
>
> You will see that you can use the Parameters
> resulting from the registration in order to
> initialize a Transform, and then use this
> transform in an itk::ResampleImageFilter.
>
> It is *strongly* recommended that you read
> first the section on resampling:
>
> Section 6.7.1, Resample Image Filter,
> in pdf-page 199, paper-page 173.
>
> Understading how the resampling works in ITK
> is fundamental for following how the registration
> framework works.
>
> You may want to look also at the description of
> Multiresolution registration on the SoftwareGuide
> Section 8.6.1, pdf-page 283, paper-page 257.
>
> For writing an image as RAW format, the easiest
> way to go is to use the Anal! yze or MetaImage formats
> which both use a text header file along with a
> raw binary file. The extension for Analyze will be
> ".hdr" while the extension for MetaImage is ".mhd".
>
>
> Regards,
>
>
>
> Luis
>
>
> -
>
> The code for resampling the moving image, once the
> registration is done, will look like (taken from
> Examples/Registration/ImageRegistration3.cxx):
>
>
>
> ParametersType finalParameters =
> registration->GetLastTransformParameters();
>
> typedef itk::ResampleImageFilter<
> MovingImageType,
> FixedImageType > ResampleFilterType;
>
> TransformType::Pointer finalTransform = TransformType::New();
>
> finalTransform->SetParameters( finalParameters );
>
> ResampleFilterType::Pointer resample = ResampleFilterType::New();
>
> resample->SetTransform( finalTransform );
> resample->SetInput( movingImageReader->GetOutput() );
>
> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
> resample->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );
> resample->SetOutputOrigin( fixedImage->GetOrigin() );
> resample->SetOutputSpacing( fixedImage->GetSpacing() );
> resample->SetDefaultPixelValue( 100 );
>
> resample->Update();
>
> writer->SetInput( resample->GetOutput() );
> writer->SetFileName("ResampledImage.hdr");
> writer->Update();
>
>
>
> ===============================================================
> -----------------------
> iajesse wrote:
> > Hi,
> >
> > I can run MultiResMIRegistration under InsightApplications-1.4.0,
> the
> > result is
> >
> > /Final parameters: [-0.0378283, -0.00839379,// 0.0137514,//
> 0.999154,
> > 11.6141, -8.60712, -5.3134]/
> >
> > /Overall transform matrix:/
> >
> > /0.999481 0.0281146 0.015733/
> >
> > /0.0268445 0.99676 -0.0758234/
> >
> > /-0.0178138 0.075! 3617 0.996997/
> >
> > /Overall transform offset:/
> >
> > /-3.26713 -4.81888 -17.0997/
> > /Does that tranform matrix means rotations transformtion M?/
> > //
> > /Is transform offset:translation T?/
> >
> > /If there is a /voxel x in the fixed image, then / y =M * x + T ,
> y is
> > the corresponding voxel in moving image.that is, I can gain the
> result
> > image using M and T, is it right?///
> > //////
> > ///If I want to save the result image as Raw format? how can I do?///
> > //////
> > ///Thanks ///
> > //////
> > ///Jesse///
> > //
> >
> >
> >
> > */Luis Ibanez /* wrote:
> >
> >
> > Hi Iajasse,
> >
> > The Examples are built by default as long
> > as at configuration time you enable
> >
> > BUILD_EXAMPLES in the CMake interface.
> >
> > The executables of the examples will be
> > created at the same t! ime that the basic
> > ITK libraries are created. That is, when
> > you built ITK you will get both the libraries
> > and the executables of the examples.
> >
> > You will find the executables in the subdirecotry
> >
> > bin/release
> > bin/debug
> >
> > of the Binary directory you provided to CMake
> > for building ITK.
> >
> > ----
> >
> > If what you want is to build an example
> > independently, then you simply need to
> > modify lightly the CMakeLists.txt file
> > that you used for HelloWorld.cxx.
> >
> > Just search/replace "HelloWorld" for
> > "Image2". Then put this CMakeLists.txt
> > file along with Image2.cxx in one external
> > directory, run CMake on them and built it.
> >
> > It will be exactly the same process you just
> > did for HelloWorld.
> >
> >
> >
> > Regards,
> >
> >
> > Luis
> >
> >
> >
> > --------------
> > iajesse wrote:
> > > Thanks for your help,
> > >
> > > The HelloWorld" can run successfully now,but when I want to know
> > how can
> > > I use Examples in my project? For example, I want to use Image2 of
> > > Examples to read the dataset. How to creat the project with itk?
> > >
> > >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail . yahoo . com
> >
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail . yahoo . com
>