[ITK-users] itk mhd header
Francois Budin
francois.budin at kitware.com
Thu Sep 15 08:52:10 EDT 2016
Hello Swetha,
The easiest way to load an mhd file is to use itkImageFileReader [1]. The
ITK Software Guide (pdf) [2]
has great examples on how to read an image in section "4.1.2 Reading an
Image from a File". This will make is much simplier to actually read the
image without having to worry about the format and the tags (ITK supports a
wide variety of formats including Meta images such as mhd and mha files).
To display the image, you will need to read:
* the size: image->GetLargestPossibleRegion().GetSize()
* the spacing: image->GetSpacing()
* the direction matrix: image->GetDirection()
* the origin: image->GetOrigin()
If you want to read the mhd file manually, it will be more complicated, but
you can look at [3].
In the case of your specific header, it seems to me that you have extra
tags that are coming from the conversion of a NIFTI image into your mhd
file (basically all the tags that start with a lower case), which makes
your header harder to read, although this will not be a problem to read
this image with ITK.
Hope this helps,
Francois
[1] https://itk.org/Doxygen/html/classitk_1_1ImageFileReader.html
[2] https://itk.org/ItkSoftwareGuide.pdf
[3] https://itk.org/Wiki/ITK/MetaIO/Documentation
On Thu, Sep 15, 2016 at 3:26 AM, swetha <swetha.bsharma at gmail.com> wrote:
> Hi,
>
> I have this mhd file header
>
> ObjectType = Image
> NDims = 3
> BinaryData = True
> BinaryDataByteOrderMSB = False
> CompressedData = False
> TransformMatrix = 1 0 0 0 1 0 0 0 1
> Offset = 0 0 0
> CenterOfRotation = 0 0 0
> AnatomicalOrientation = RAI
> ElementSpacing = 1 1 1
> bitpix = 8
> cal_max = 256
> cal_min = 0
> datatype = 2
> dim[0] = 4
> dim[1] = 480
> dim[2] = 480
> dim[3] = 256
> dim[4] = 1
> dim[5] = 1
> dim[6] = 0
> dim[7] = 0
> dim_info =
> intent_code = 0
> intent_p1 = 1.86143e+034
> intent_p2 = 0
> intent_p3 = 0
> pixdim[0] = 0
> pixdim[1] = 1
> pixdim[2] = 1
> pixdim[3] = 1
> pixdim[4] = 0
> pixdim[5] = 0
> pixdim[6] = 0
> pixdim[7] = 0
> qform_code = 0
> qoffset_x = 0
> qoffset_y = 0
> qoffset_z = 0
> quatern_b = 0
> quatern_c = 0
> quatern_d = 0
> scl_inter = 0
> scl_slope = 1
> sform_code = 0
> slice_code =
> slice_duration = 0
> slice_end = 0
> slice_start = 0
> srow_x = 0 0 0 0
> srow_y = 0 0 0 0
> srow_z = 0 0 0 0
> toffset = 0
> vox_offset = 0
> xyzt_units =
> DimSize = 480 480 256
> ElementType = MET_SHORT
> ElementDataFile = usg2_-2.raw
>
> I want to know what the tags mean so that i can write a function to parse
> and display the image.
> -swetha
>
>
>
>
> --
> View this message in context: http://itk-insight-users.
> 2283740.n2.nabble.com/itk-mhd-header-tp7589210.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
> _____________________________________
> 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/20160915/7ede31c7/attachment.html>
More information about the Insight-users
mailing list