[Insight-users] Image corner index

Luis Ibanez luis.ibanez at kitware.com
Sun Nov 8 14:33:37 EST 2009


Hi  Yi,

Thanks for pointing this out.

You are right...

The fact is that most image file formats do not store the
starting index of the image.

The few that may use this information, (e.g. MetaImage)
will instead interpret it as a hint on how to do streaming
on the output image file.

Apart from that, most image file formats simply assume
that the starting index of the image is (0,0,0).

I guess that you could call this a bug...
but there is not much that ITK could do to compensate
for deficiencies of established image file formats, except
maybe for printing out some warning when you attempt
to save an image with non-zero starting index using a
file format that can not represent this information.

Along the same lines, we would have to also print
warnings when you attempt to write out an image with
non-identity direction matrix into a file format that
can not represent this information (e.g. PNG, JPEG,
TIFF, VTK....)

Please feel free to add a bug (or feature request) entry
to the bug tracker:

http://public.kitware.com/Bug/my_view_page.php



     Regards,


            Luis



------------------------------------------------------------------------------
On Wed, Nov 4, 2009 at 11:25 AM, Gao, Yi <gaoyi.cn at gmail.com> wrote:
> 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
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list