[Insight-users] Calculating a Similarity Measure.
Luis Ibanez
luis.ibanez@kitware.com
Tue May 18 17:02:59 EDT 2004
Hi Josiane,
A) The GetMetric() method was added recently to
the DemonsRegistrationFilter.
Please use the CVS checkout version of ITK.
B) Your code for the Subtract image filter looks
fine. How are you arriving to the conclusion
that all the values are zero ?
What file format are you using for saving the
difference image ?
Did you loaded the image into a viewer and
found the image to be black ?
Did you put the image in to the MaximumMinimum
calculator and found the min and max values to
be zero ?
It is very likely that you actually have some
values in the difference image...
You could save the image in a format such as
MetaImage and then load it in a viewer like
ParaView. http://www.paraview.org.
Please let us know,
Thanks
Luis
---------------------------------------------------
Josiane Yankam Njiwa--DEA Clarysse--Fin 11/04 wrote:
> Hi Luis,
>
> Thanks a lot for your help. I have read the tutorial and have learned a
> lot. I have some questions but i will expose later.
> Before my main topic today, i would like to mention that the method
> std::cout << filter->GetMetric() << std::endl; doesn't work at the
> compilation the program return and message error which is GetMetric is not
> a member of DemonFilter.
>
>
>
> My problem today, is the following: To have the Difference of two images,
> itk propose SquareDifferenceImageFilter( which in my case doesn't give
> results which are expessive), so i hope to use another itk class which is
> itk::SubtractImageFilter, i have wrote the source below, but when i run
> it,i have nothing in the difference image, all the values are 0.
> I don't see, where i am wrong.
>
>
> Thanks with regards
>
> Josiane.
>
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkSubtractImageFilter.h"
> #include "itkCastImageFilter.h"
>
>
> #include "itkImage.h"
>
>
> int main( int argc, char ** argv )
> {
> // Verification du nombre de paramètres en arguments
> if( argc < 4 )
> {
> std::cerr << "Usage: " << std::endl;
> std::cerr << argv[0] << " inputFile1 inputFile2 Diff" << std::endl;
> return -1;
> }
>
>
> typedef unsigned char PixelType;
> typedef float PixelTypeI;
> const unsigned int Dimension = 2;
> typedef itk::Image< PixelType, Dimension > ImageType;
> typedef itk::ImageFileReader< ImageType > ReaderType;
>
>
>
> ReaderType::Pointer reader = ReaderType::New();
> ReaderType::Pointer reader1 = ReaderType::New();
>
>
> reader->SetFileName( argv[1]);
> reader1->SetFileName( argv[2] );
> reader->Update();
> reader1->Update();
>
> /*----------Changing pixel type to float----------------------------------*/
>
> typedef itk::Image< PixelTypeI, Dimension > ImCast;
> typedef itk::CastImageFilter<
> ImageType,
> ImCast > CastFilterType;
>
> CastFilterType::Pointer caster = CastFilterType::New();
> CastFilterType::Pointer caster1 = CastFilterType::New();
> caster->SetInput( reader->GetOutput() );
> caster1->SetInput( reader1->GetOutput() );
>
> /*----------Compute Image of difference----------------------------------*/
>
>
> typedef itk::ImageFileWriter< ImCast> WriterType;
> typedef itk::SubtractImageFilter<ImCast,ImCast,ImCast>
> DifferenceFilterType;
>
> WriterType::Pointer writer = WriterType::New();
>
> DifferenceFilterType::Pointer difference = DifferenceFilterType::New();
> difference->SetInput1( caster->GetOutput() );
> difference->SetInput2( caster1->GetOutput() );
>
>
> if( argc >= 3 )
> {
> writer->SetFileName( argv[3] );
> writer->SetInput( difference->GetOutput() );
> writer->Update();
> }
>
>
> try
> {
> writer->Update(); // Mise à jour du writer donc on peut faire une lecture
>
> }
> catch( itk::ExceptionObject & err )
> {
> std::cout << "ExceptionObject caught !" << std::endl;
> std::cout << err << std::endl;
> return -1;
> }
> return 0;
> }
>
>
>
>
>
>
>>Hi Josiane,
>>
>>Please read the Chapter on deformable
>>registration in the SoftwareGuide.
>>
>> htt://www.itk.org/ItkSoftwareGuide.pdf
>>
>>Chapter 8, pdf-page 241-340.
>>
>>Pay particular attention to section 8.1
>>describing the basic registration framework
>>and to section 8.12 describing the deformable
>>registration methods.
>>
>>
>>You will find that the methods described in
>>DeformableRegistration1.cxx and Deformable
>>Registration2.cxx do not belong to the basic
>>registration framework in ITK.
>>
>>
>>The DemonsRegistrationfilter has its own
>>method for returning the metric used for
>>the registration. This is indeed a mean
>>squares metric.
>>
>>You will find in line 79 of
>>
>> Insight/Examples/Registration/
>> DeformableRegistration2.cxx
>>
>>the following code
>>
>> std::cout << filter->GetMetric() << std::endl;
>>
>>where "filter" is the DemonsRegistrationFilter.
>>
>>
>>
>>--
>>
>>If what you want is to evaluate the final quality
>>of the registration, what you could do is to take
>>the fixed image and the warpped moving image (the
>>output of the WarpImageFilter) and pass them as
>>input to your arbitrary metric, using an Identity
>>transform...
>>
>>
>>--
>>
>>Before you continue, I would *strongly* suggest
>>you to read the chapter on registration from
>>the SoftwareGuide and the Tutorials on registration
>>
>> http://www.itk.org/HTML/Tutorials.htm
>>
>>Basic registration framework
>>http://www.itk.org/CourseWare/Training/RegistrationMethodsOverview.pdf
>>
>>Deformable registration
>>http://www.itk.org/CourseWare/Training/NonRigidRegistrationMethods.pdf
>>
>>I'm affraid that you are miss-interpreting the way
>>Metrics, Transforms and RegistrationMethods work
>>together.
>>
>>
>>Please let us know if you have further questions
>>after your reading.
>>
>>
>> Thanks
>>
>>
>>
>> Luis
>>
>>
>>--------------------------------------------------------
>>Josiane Yankam Njiwa--DEA Clarysse--Fin 11/04 wrote:
>>
>>
>>>Hi
>>>
>>>I want to calculate similarity measure in the case of using
>>>DeformableRegistration1.cxx and DeformableRegistration2.cxx.
>>>For the second example, i try to connect a metric to the warp filter and
>>>it doesn't work. I don't how to use the fact that i have a registration
>>>procedure to get my similarity measure.
>>>I have read carefully the registration examples, but i haven't solve my
>>>problème.
>>>Thank for you help.
>>>
>>>Josiane
>>>
>>>
>>>
>>>
>>
>>
>
>
More information about the Insight-users
mailing list