[Insight-users] Masks & registration

Luis Ibanez luis.ibanez at kitware.com
Thu May 11 08:14:30 EDT 2006


Hi Paul,


The Metric *does* take into account the Moving massk.


The pseudo code of the metric is as follow:


     for all pixels in the Fixed image
       {
       if pixel is inside Fixed image mask
          {
          map pixel index to a point in Fixed image coordinates

          use Transform to map point in Fixed coordinate to
          point in Moving coordinate

          map point from Moving coordinates to Index in Moving
          image grid

          if pixel in moving image is inside Moving Image Mask
            {
            compute the contibutions of Fixed and Moving pixel
            to the total Metric
            }

         }
      }


Please enjoy the pleasure of Open Source software:

Go to the file:


     Insight/
           Code/
              Algorithms/
                 itkMeanSquaresImageToImageMetric.txx


open the file and take a look at lines 67 to 99.


There is no need for speculation when all the information needed
for answering question is available in plain view. The cultural
value of Open Source is not just the fact of having software
available gratis, it is rather the fact of sharing the knowledge
on "how" this software was developed, and from that getting
community feedback in order to improve it.


You will find similar code in any of the ImageToImage metrics
available in that directory.


You should read the "Image Registration" chapter in the ITK
Software Guide:


       http://www.itk.org/ItkSoftwareGuide.pdf

and you should read the Tutorials:

      http://www.itk.org/HTML/Tutorials.htm

in particular the one on Image Registration:

  http://www.itk.org/CourseWare/Training/RegistrationMethodsOverview.pdf




    Please let us know if you have further questions.


       Thanks


          Luis



----------------------
Laurent PAUL wrote:
> Hi Karthik,
> 
> If I understand what it means (sorry I'm french! I'm not english fluent
> speaking), MovingMask is tranformed with the initialTransform provided by
> te initializer.
> If so, I don't understand why metric is never computed when I use
> MovingMask...
> 
> Laurent.
> 
> 
> 
>>See this post
>>http://public.kitware.com/pipermail/insight-users/2005-April/012650.html
>>
>>HTH
>>-karthik
>>
>>Laurent PAUL wrote:
>>
>>
>>>Hi Luis,
>>>
>>>If I want to use masks, I can first apply a AND filter on Image and Mask
>>>and use the result as fixed and moving Image.
>>>If I really need masks, I'll try.
>>>
>>>Another question on masks: if I use mask, Do I have to initially
>>>transform
>>>the mask with the same InitialTransform applied on the MovingImage? I
>>>think my problem could come from there, mask hasn't the same absolute
>>>coordinates as Initially transformed MovingImage.
>>>
>>>Thanks for your help.
>>>
>>>Laurent.
>>>
>>>
>>>
>>>
>>>
>>>>Hi Laurent,
>>>>
>>>>The Transform Initializers do not take into account the Masks.
>>>>
>>>>They compute the Moments/Geometry on the entire images.
>>>>
>>>>Note that a better way to initialize your registration is to
>>>>use the LandmarkBasedTransformInitializer.
>>>>
>>>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1LandmarkBasedTransformInitializer.html
>>>>
>>>>It requires the user to provide at couple of homologous points
>>>>in both images, but it will increase a lot the quality of your
>>>>initialization.
>>>>
>>>>
>>>>
>>>>  Regards,
>>>>
>>>>
>>>>     Luis
>>>>
>>>>
>>>>
>>>>======================
>>>>Laurent PAUL wrote:
>>>>
>>>>
>>>>
>>>>>Hi users,
>>>>>I've got a problem with masks & registration.
>>>>>I use MeanSquaresImageToImageMetric and VersorRigid3DTransform for the
>>>>>
>>>>>
>>>
>>>registration process.
>>>
>>>
>>>
>>>>>Since I have regions of interest, I tried to pass at least 1 mask to
>>>>>
>>>>>
>>>
>>>the
>>>
>>>
>>>
>>>>>metric. It seems to be ok as I test it with IsInside() method with two
>>>>>
>>>>>
>>>
>>>points (one in and one out).
>>>
>>>
>>>
>>>>>My first question is if I use SetDefaultOutsideValue(0) for the mask,
>>>>>
>>>>>
>>>
>>>any value different from 0 will be considered as Inside, right?
>>>
>>>
>>>
>>>>>Then, I read a message which deals with nearly the same problem:
>>>>>
>>>>>
>>>
>>>http://public.kitware.com/pipermail/insight-users/2005-September/014948.html
>>>This is an (interesting) extract:
>>>
>>>
>>>
>>>>>>"Sure, as you pointed out, if you start off with a horrible initial
>>>>>>
>>>>>>
>>>
>>>misalignment, in the worst case, the regions don't overlap and the
>>>
>>>
>>>
>>>>>>metric
>>>>>>never gets computed.  Usually, in a registration application, if
>>>>>>you've
>>>>>>
>>>>>>
>>>
>>>gone through the trouble of specifying relevant regions in both the
>>>
>>>
>>>
>>>>>fixed >and moving image regions, you already have some idea of the
>>>>>
>>>>>
>>>
>>>initial >transform and there is no excuse for not specifying an initial
>>>transform >that guarantees significant overlap between the two masks.
>>>
>>>
>>>
>>>>>>(This will of course only happen if you've specified *both* a fixed
>>>>>>and
>>>>>>
>>>>>>
>>>
>>>moving image mask, and not if just specify one of them. )"
>>>
>>>
>>>
>>>>>I am in this case, where I know regions of interest.
>>>>>I understand the intialization problem but how initialize the
>>>>>registration?
>>>>>So far, I used the CenteredVersorTransformInitializer:
>>>>>  initializer->SetTransform (transform);
>>>>>  initializer->SetFixedImage (FixedImage);
>>>>>  initializer->SetMovingImage (MovingImage);
>>>>>  initializer->MomentsOn();
>>>>>What I understood is that initialisation is made upon Mass center. Is
>>>>>
>>>>>
>>>
>>>mass center calculation takes account of the mask, I mean only region
>>>contained in the mask?
>>>
>>>
>>>
>>>>>I tried too with initializer->GeometryOn();
>>>>>but I've got an error at runtime. Is it safe to use "GeometryOn"? More,
>>>>>
>>>>>
>>>
>>>I know initialisation is quite ok. There is just a translation error.
>>>
>>>
>>>
>>>>>I tried (without using Initializer):
>>>>> TransformType::OutputVectorType InitialTranslation;
>>>>> InitialTranslation[0] = 80;
>>>>> InitialTranslation[1] = 0;
>>>>> InitialTranslation[2] = 0;
>>>>> transform->SetTranslation( InitialTranslation );
>>>>>Registration's result is bad and stops. I saw that transform center is
>>>>>
>>>>>
>>>
>>>[0,0,0].
>>>
>>>
>>>
>>>>>So, I first use intializer (to compute transform center) and
>>>>>OverrideTranslation with mine.
>>>>>Is there a better way to initialise the registration?
>>>>>If I specify a MovingMask, even with good initialization, registration
>>>>>
>>>>>
>>>
>>>stops with this error message: All the points mapped to outside of the
>>>moving volume.
>>>
>>>
>>>
>>>>>So, my last question is: Is mask initialized with the initialtransform?
>>>>>
>>>>>
>>>
>>>Sorry for the long message but I had to be clear.
>>>
>>>
>>>
>>>>>Laurent.
>>>>>_______________________________________________
>>>>>Insight-users mailing list
>>>>>Insight-users at itk.org
>>>>>http://www.itk.org/mailman/listinfo/insight-users
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>>
>>
> 
> 
> _______________________________________________
> 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