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

Todd Jensen todd.jensen at ieee.org
Thu Mar 9 14:11:00 EST 2017


> From: Sarthak P <scapegoat.sarthak at gmail.com <mailto:scapegoat.sarthak at gmail.com>>
> To: Matt McCormick <matt.mccormick at kitware.com <mailto:matt.mccormick at kitware.com>>
> Cc: "insight-users at itk.org <mailto:insight-users at itk.org>" <insight-users at itk.org <mailto:insight-users at itk.org>>
> Subject: Re: [ITK] [ITK-users] Writing a DICOM file while preserving
> 	input	image	properties
> Message-ID:
> 	<CAEcjzFHR+hm0-mM3biCXpzhaOv=M+G5FVO1sG+9mnz8SFRr5Dw at mail.gmail.com <mailto:CAEcjzFHR+hm0-mM3biCXpzhaOv=M+G5FVO1sG+9mnz8SFRr5Dw at mail.gmail.com>>
> Content-Type: text/plain; charset="utf-8"
> 
> So the thing is that even the origin isn't picked up when reading the DICOM
> image (it is always 0,0,0) so I am guessing I am doing something wrong when
> writing into the tag 0020|0032 itself. Once that is rectified, the spacing
> information (should) correct itself.
> 

I also had to add code to handle the origin and direction to the new Write method in the extended class (see previous message):

	double ipp[ 3 ] = { 0 };
	if ( itk::ExposeMetaData< vcl_string >( dict, "0020|0032", tmpStr ) )
	{
		if ( sscanf( tmpStr.c_str(), "%lf\\%lf\\%lf", &ipp[ 0 ], &ipp[ 1 ], &ipp[ 2 ] ) == 3 )
		{
			for ( unsigned int i = 0; i < 3; i++ )
			{ 
				m_Origin[ i ] = ipp[ i ];
			}
		}
		else
		{
			// error
		}
	}
	double dir[ 6 ] = {1,0,0,0,1,0};
	if ( itk::ExposeMetaData< vcl_string >( dict, "0020|0037", tmpStr ) )
	{
		if ( sscanf( tmpStr.c_str(), "%lf\\%lf\\%lf\\%lf\\%lf\\%lf", &dir[ 0 ], &dir[ 1 ], &dir[ 2 ] , &dir[ 3 ], &dir[ 4 ], &dir[ 5 ] ) == 6 )
		{
			for ( unsigned int i = 0; i < 2; i++ )
			{
				for ( unsigned int j = 0; j < 3; j++ )
				{
					m_Direction[ i ][ j ] = dir[ ( i * 3 ) + j ];
				}
			}
		}
		else
		{
			// error
		}
	}
	

I also had to add code to handle the origin and direction to the new Write method in the extended class (see previous message).

Todd

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170309/addef414/attachment-0001.html>


More information about the Community mailing list