[ITK-users] [ITK] CorrelationImageToImageMetricv4 returns 0 from GetValue()

Dženan Zukić dzenanz at gmail.com
Fri Aug 26 16:50:14 EDT 2016


Hi Andrew,

the problem was that you were setting the mask to just the white box. This
caused the metric to only be evaluated on one pixel intensity, which is a
degenerate case and is probably what caused the correlation to be 0.
Without setting either mask, the registration does something - I did not
examine whether the result is correct or even meaningful. The modified
files are attached - you can do a diff to see the few differences.

If you need the mask for a similar case in practice, you could use dilate
filter to enlarge the mask by a few voxels.

Regards,
Dženan

On Fri, Aug 26, 2016 at 3:14 PM, Andrew Harris <aharr8 at uwo.ca> wrote:

> Sorry again for the delay, we determined the images we were creating were
> too big so we created a smaller phantom image, attached.  In addition,
> there is a main() function in CorrelationTest.cpp that runs the correlation
> and outputs it to  a file called observer.txt, and I have included the most
> up-to-date versions of my class and header files.  The function is
> expecting the phantom to exist in a folder at c:/Scans/Phantom.  Let me
> know if you need further info, and thanks again for your help.​
>  SmallPhantomBox.raw
> <https://drive.google.com/file/d/0B_DYTA-i186ZenpOTzUxekVhaU0/view?usp=drive_web>
> ​​
>  CorrelationTest.cpp
> <https://drive.google.com/file/d/0B_DYTA-i186ZT3pjaWtrbkRzeFE/view?usp=drive_web>
> ​​
>  Correlator3D.cpp
> <https://drive.google.com/file/d/0B_DYTA-i186ZM3dwRXNiU1JEems/view?usp=drive_web>
> ​​
>  Correlator3D.h
> <https://drive.google.com/file/d/0B_DYTA-i186ZQ25EbjMtZkxJVlU/view?usp=drive_web>
>>
> --
>
> AH
>
>
> ------------------------------------------------------------
> -----------------------------------
>
> *This email and any attachments thereto may contain private,
> confidential, and privileged materials for the sole use of the intended
> recipient. Any reviewing, copying, or distribution of this email (or any
> attachments thereto) by other than the intended recipient is strictly
> prohibited. If you are not the intended recipient, please contact the
> sender immediately and permanently destroy this email and any attachments
> thereto.*
>
> On Tue, Aug 23, 2016 at 9:53 AM, Dženan Zukić <dzenanz at gmail.com> wrote:
>
>> Hi Andrew,
>>
>> you are doing so many things in a nonstandard way, starting with passing
>> around pointers to buffers and metadata as plain parameters, instead of
>> just once converting to itk::Image and then using itk::Image::Pointer to
>> pass the images around. Your approach is more prone to errors.
>>
>> Can you provide the inputs and the main function which invokes this class
>> to have a runnable example? I will try to find the problem.
>>
>> Regards,
>> Dženan
>>
>> On Mon, Aug 22, 2016 at 3:25 PM, Andrew Harris <aharr8 at uwo.ca> wrote:
>>
>>> Hello all,
>>> I am having a devil of a time setting up the
>>> CorrelationImageToImageMetricv4 and getting a result that makes sense.
>>> I have written an observer that outputs to a text file the iteration
>>> number, correlation value, and current position.  I have generated a
>>> virtual phantom image of a white cube on a black background, and when I put
>>> the same image through for fixed and moving images, I get [0,0,0,0,0,0],
>>> meaning that no rotation or translation is required for the images to be
>>> aligned.  This is the correct versor and vector transform, and if I apply a
>>> translation the correct distance values are returned to have the images
>>> align, however the metric value returned is also 0 and a perfect
>>> registration like this should yield a metric of -1 according to the
>>> documentation.  Additionally, it doesn’t seem to be analyzing rotation
>>> properly, as when I introduce a rotation around any axis the metric returns
>>> a translation on the other two axes but the rotation versor remains at zero.
>>>
>>> I’m attaching my code as well, it’s possible I’ve not set some
>>> parameters up properly:
>>>
>>>
>>> --
>>>
>>> AH
>>>
>>>
>>> ------------------------------------------------------------
>>> -----------------------------------
>>>
>>> *This email and any attachments thereto may contain private,
>>> confidential, and privileged materials for the sole use of the intended
>>> recipient. Any reviewing, copying, or distribution of this email (or any
>>> attachments thereto) by other than the intended recipient is strictly
>>> prohibited. If you are not the intended recipient, please contact the
>>> sender immediately and permanently destroy this email and any attachments
>>> thereto.*
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment.html>
-------------- next part --------------
Iteration: 0 Calculation: 1 Value = -0.714321 Position: [0, 0, 0, 0, 0, 0]
Iteration: 0 Calculation: 2 Value = 0 Position: [-0.44869711458819234, -0.3193438163428909, 0.8322332598948731, -0.03702978345737059, 0.05202905520612079, 7.648517331413413e-11]
Iteration: 0 Calculation: 3 Value = -0.259188 Position: [-0.05356018556689876, -0.03811950981379673, 0.09934222081152533, -0.004420180137104539, 0.00621061683061597, 9.129900644850814e-12]
Iteration: 0 Calculation: 4 Value = -0.741777 Position: [-0.0018972980288040964, -0.0013503327156766355, 0.003519065472379799, -0.00015657897694571133, 0.0002200028051745136, 3.234145347576637e-13]
Iteration: 0 Calculation: 5 Value = -0.741777 Position: [-0.0018972980288040964, -0.0013503327156766355, 0.003519065472379799, -0.00015657897694571133, 0.0002200028051745136, 3.234145347576637e-13]
Iteration: 1 Calculation: 6 Value = -0.764069 Position: [-0.008864090218485405, -0.007374896592515705, 0.020338116205582384, -0.0006576375484633565, 0.0012860372951096447, 0.00022307664983305773]
Iteration: 1 Calculation: 7 Value = -0.764069 Position: [-0.008864090218485405, -0.007374896592515705, 0.020338116205582384, -0.0006576375484633565, 0.0012860372951096447, 0.00022307664983305773]
Iteration: 2 Calculation: 8 Value = -0.768639 Position: [-0.007362369143132123, -0.005453990604406128, 0.01819539033060534, -0.0003739565466923287, 0.0012063875812397637, 0.0002982793118707005]
Iteration: 2 Calculation: 9 Value = -0.768639 Position: [-0.007362369143132123, -0.005453990604406128, 0.01819539033060534, -0.0003739565466923287, 0.0012063875812397637, 0.0002982793118707005]
Iteration: 3 Calculation: 10 Value = -0.769345 Position: [-0.0063722110784427445, -0.004674860804162271, 0.01869368990204535, -0.0001296212038001693, 0.0012940408600778173, 0.0004709802964571845]
Iteration: 3 Calculation: 11 Value = -0.769345 Position: [-0.0063722110784427445, -0.004674860804162271, 0.01869368990204535, -0.0001296212038001693, 0.0012940408600778173, 0.0004709802964571845]
Iteration: 4 Calculation: 12 Value = -0.771464 Position: [0.007388884078228691, 0.008516254318087854, 0.0293297785177389, 0.003835853083661105, 0.00290783602505402, 0.0032057741175897177]
Iteration: 4 Calculation: 13 Value = -0.771464 Position: [0.007388884078228691, 0.008516254318087854, 0.0293297785177389, 0.003835853083661105, 0.00290783602505402, 0.0032057741175897177]
Iteration: 5 Calculation: 14 Value = -0.771616 Position: [0.03099193061558464, 0.032248721416564013, 0.05173840999553268, 0.011093456031267445, 0.006026166796194969, 0.008235101260558113]
Iteration: 5 Calculation: 15 Value = -0.771616 Position: [0.03099193061558464, 0.032248721416564013, 0.05173840999553268, 0.011093456031267445, 0.006026166796194969, 0.008235101260558113]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tester.cpp
Type: text/x-c++src
Size: 1141 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Correlator3D.cpp
Type: text/x-c++src
Size: 18667 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment-0001.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Correlator3D.h
Type: text/x-chdr
Size: 4592 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rotatedImage.nrrd
Type: application/octet-stream
Size: 1366 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixedImage.nrrd
Type: application/octet-stream
Size: 1159 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160826/87c34d3b/attachment-0001.obj>


More information about the Insight-users mailing list