[Fwd: Re: [Insight-users] PointsetToImageRegistrationMethod]

Luis Ibanez luis.ibanez at kitware.com
Tue, 23 Mar 2004 15:11:34 -0500


This is a multi-part message in MIME format.
--------------010002040202020009020601
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit


Hi David,

You can get it by any of the following methods:


A) Downloading the CVS version of ITK
    (if you don't get this file after an update,
     this probably means that you have sticky
     tags in your checkout, in that case you should
     update using the command:    cvs -dPA


B) Downloading it from the following URL link
http://www.itk.org/cgi-bin/cvsweb.cgi/Insight/Examples/DataRepresentation/Mesh/ImageToPointSet.cxx?cvsroot=Insight



C) Taking it from the attachment of this very email,  :-)


Regards,


    Luis


-----------------------------
David Macias Verde wrote:

> Dear Luis:
> 
> Thank you very much for your wise help.
> 
> I know it is the second time I ask you for it, but I sincerely cannot 
> find Insight/Examples/DataRepresentation/Mesh/ImageToPointSet.cxx 
> anywhere. Could you please tell where to go and get it? I've downloaded 
> again the whole distribution but it's not in.
> 
> Regards,
> 
> David Macías
> 
> 
> 
> 
> -----Forwarded Message-----
> 
>>*/From:/*/ Luis Ibanez <luis.ibanez at kitware.com>
>>*To:* dmacver at gobiernodecanarias.org
>>*Cc:* ITK Users <insight-users at public.kitware.com>
>>*Subject:* Re: [Insight-users] PointsetToImageRegistrationMethod
>>*Date:* Tue, 23 Mar 2004 10:10:55 -0500
>>
>>
>>Hi David,
>>
>>Matching Canny edges of the Moving image against
>>the Distance map of the Fixed image Canny edges
>>is a great idea.
>>
>>The only trick is that the MeanSquaresMetric is
>>not what you can use for such matching.  This
>>metric tries to minimize the difference between
>>the pixel values of your canny edge map and the
>>values of the Distance map.  Since the canny edges
>>are bright (high values), and the Distance map values
>>are zero over the fixed image edges, the optimization
>>necessarily will climb up in the distance map, looking
>>for higher values, that unfortunately correspond to
>>larger distances to the fixed image edges.
>>
>>You need a metric that will be optimal when the bright
>>pixels of the moving-image canny-edges will be on the
>>*zero* values of the distance map.
>>
>>A possible metric could be to simply compute the sum of
>>the distance map values that are the images of the moving
>>image canny edges under the spatial transform.
>>
>>You can implement this metric in a very efficient way
>>by creating a PointSet from your Canny edges moving image.
>>For this purpose you can use the new example:
>>
>>    Insight/Examples/DataRepresentation/Mesh/
>>                         ImageToPointSet.cxx
>>
>>and simply add an if() condition inside the for() loop
>>in order to generate points only in the pixels corresponding
>>to edges. Once you get this PointSet, you can create a new
>>PointSetToImageMetric base on a criterion like the one we
>>mention above (e.g. sum of distance map values).
>>
>>Note that you can do even better by taking advantage
>>of the fact that the DanielssonDistanceMap not only
>>tells you how far you are from the edges, it also tells
>>you in what direction to move in order to get closer.
>>If you use this information you coud feed the Levenberg-
>>Marquardt optimizer and perform registration at very
>>high speed.  Similar techniques are the ones used for
>>performing registration in Image Guided Surgery where
>>you need almost real-time registration.
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>
>>-----------------------------------
>>David Macias Verde wrote:
>>> Hi all:
>>> 
>>> I'm sorry for this silly question, but I am new to ITK (and also the 
>>> rest of the basic things, as C++, VTK, Qt, which are the tools I'm 
>>> trying to bring together). To me I see a huge field for just an apprentice.
>>> 
>>> At this time I'm doing rigid registration in the following manner:
>>> 
>>> FixedImage                                         MovingImage
>>>       ||                                                     ||
>>>       \/                                                     \/ 
>>> itkCannyEdgeDetectorFilteri                         
>>> itkCannyEdgeDetectorFilter
>>>       ||                                                    
>>>       \/                                                   
>>> itkDanielssonDistanceMapImageFilter
>>> 
>>>                                        ||
>>>                                        ||
>>>                                        ||
>>>                                        \/
>>>                               itkTranslationTransform
>>>                                        ||
>>>                                        \/
>>>                       itkRegularStepGradientDescentOptimizer
>>>                                        ||
>>>                                        \/
>>>                        itkMeanSquaresPointSetToImageMetric
>>>                                        ||
>>>                                        \/
>>>                           itkLinearInterpolateImageFunction
>>>                                        ||
>>>                                        \/
>>>                         itkPointsetToImageRegistrationMethod
>>> 
>>> The trouble I get is that the images, far to converge, go the other way 
>>> round. The results of the registration algorithm are:
>>> 
>>> Result =Translation X = -90.4793
>>> Translation Y = 103.5
>>> Iterations    = 99
>>> Metric value  = 1.04037e+09
>>> 
>>> Could anyone give a hint on how I can solved this to cross over such a task?
>>> 
>>> Thanks in advance,
>>> 
>>> -- 
>>> David Macias Verde <_david.maciasverde at gobiernodecanarias.org_ 
>>> <mailto:david.maciasverde at gobiernodecanarias.org>>
>>> Servicio de Física Médica - Hospital de Gran Canaria Dr. Negrín
>>> 
>>
>>/
>>
> -- 
> David Macias Verde <_david.maciasverde at gobiernodecanarias.org_ 
> <mailto:david.maciasverde at gobiernodecanarias.org>>
> Servicio de Física Médica - Hospital de Gran Canaria Dr. Negrín
> 
> 


--------------010002040202020009020601
Content-Type: text/plain;
 name="ImageToPointSet.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="ImageToPointSet.cxx"

Lyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09DQoNCiAgUHJvZ3JhbTogICBJbnNpZ2h0IFNlZ21lbnRh
dGlvbiAmIFJlZ2lzdHJhdGlvbiBUb29sa2l0DQogIE1vZHVsZTogICAgJFJDU2ZpbGU6IElt
YWdlVG9Qb2ludFNldC5jeHgsdiAkDQogIExhbmd1YWdlOiAgQysrDQogIERhdGU6ICAgICAg
JERhdGU6IDIwMDQvMDMvMjAgMTg6MTQ6MzAgJA0KICBWZXJzaW9uOiAgICRSZXZpc2lvbjog
MS4xICQNCg0KICBDb3B5cmlnaHQgKGMpIEluc2lnaHQgU29mdHdhcmUgQ29uc29ydGl1bS4g
QWxsIHJpZ2h0cyByZXNlcnZlZC4NCiAgU2VlIElUS0NvcHlyaWdodC50eHQgb3IgaHR0cDov
L3d3dy5pdGsub3JnL0hUTUwvQ29weXJpZ2h0Lmh0bSBmb3IgZGV0YWlscy4NCg0KICAgICBU
aGlzIHNvZnR3YXJlIGlzIGRpc3RyaWJ1dGVkIFdJVEhPVVQgQU5ZIFdBUlJBTlRZOyB3aXRo
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