[ITK] [ITK-users] Writing a DICOM file while preserving input image properties

Todd Jensen todd.jensen at ieee.org
Thu Mar 9 14:05:54 EST 2017







> Hi Matt,
> 
> Yes I do know that. I have tried to put the spacing information from the
> itk::Image using various combinations with the tags 0018|0088 (slice
> thickness) and 0018|0050 (spacing between slices) but to no avail.
> 
> Thanks for your help,
> Sarthak

I was having this same issue until I extended the GDCMImageIO class as it overrides the spacing no matter what you set in the tag. I had to copy the Write() method, and add lines similar to:

	vcl_string tmpStr;
	if ( itk::ExposeMetaData< vcl_string >( dict, "0018|0088", tmpStr ) )
	{
		m_Spacing[2] = atof( tmpStr.c_str() );
	}

before the following code:
	
	gdcm::SmartPointer<gdcm::Image> simage = new gdcm::Image;
	gdcm::Image &image = *simage;
	image.SetTransferSyntax( gdcm::TransferSyntax::ExplicitVRLittleEndian );
	image.SetNumberOfDimensions( 2 ); // good default
	image.SetDimension(0, m_Dimensions[0] );
	image.SetDimension(1, m_Dimensions[1] );
	image.SetSpacing(0, m_Spacing[0] );
	image.SetSpacing(1, m_Spacing[1] );
	image.SetSpacing(2, m_Spacing[2] );


I hope this helps,

Todd

Todd Jensen, PhD
Jensen Informatics LLC
https://about.me/todd.jensen <http://www.linkedin.com/in/toddjensen>
+1 (262) 682-0143
todd at jenseninformatics.com

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170309/b9a59015/attachment-0001.html>


More information about the Community mailing list