[Insight-users] Image corner index

Gao, Yi gaoyi.cn at gmail.com
Wed Nov 4 11:25:57 EST 2009


Hi all,

Just to share some observations of the behavior of the index of the
corner pixel/voxel of itk::image.
Please correct me if I'm wrong.

The corner index of itk::Image, the one we set by
img->GetLargestPossibleRegion().SetIndex(),
performs differently after saving to a file and loaded again:

    We create an itk::Image similar to the example
“Example/DataRep.../Image/Image1.cxx”.
Except that the “start” variable is 10, 20 (// assume 2D)

    Then cout<<img->GetLargestPossibleRegion().GetIndex()<<endl; will
give [10, 20].

    Also, if we want to access the intensity of the corner pixel we do:
   ImageType::IndexType idx = {{10, 20}};
   cout<<img->GetPixel(idx)<<end;


    Now we save img to a nrrd file, and load it back again, called img1.
    This time, do cout<<img->GetLargestPossibleRegion().GetIndex()<<endl;
will give [0, 0].

    Moreover, if we want to access the intensity of the corner pixel we do:
   ImageType::IndexType idx = {{0, 0}}; //instead of 10, 20
   cout<<img1->GetPixel(idx)<<end;

    However, this is not a bug because the [10, 20] info does not get lost in
save/load. In the nrrd file, it is stored in the “space origin” item. However, as
we tested above, that info does not affect the corner index of the loaded file.

    So we can conclude that when an image is loaded in, the
cout<<img->GetLargestPossibleRegion().GetIndex();
is always [0, 0].


Hope this is useful for those who are dealing with the coordinates.
And please let me know if I get anything wrong.

Thanks,
yi


More information about the Insight-users mailing list