Felix,<br><br>Use itkChangeInformationImageFilter to change spacing,origin,direction...<br><br>Bill<br><br><div class="gmail_quote">On Jan 24, 2008 12:28 PM,  &lt;<a href="mailto:bollen@ipk-gatersleben.de">bollen@ipk-gatersleben.de</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Bill,<br><br>Yes, a default value coming from MATLABs libtiff is 76px per inch-may I<br>should try to change it on the data generation side...<br>
<br>I know TIF (custom) tags themself are quite an issue. I have read<br>through some posts regarding SetSpacing() and that its use is<br>discouraged within ITK for obvious reasons.<br><br>Could you give any suggestions how to circumvade the problem in<br>
reading/writing the TIFs with different spacing by setting the spacing<br>manually?<br><br>I tried to change the spacing directly on the caster-&gt;GetOutput()<br>without effect as it is const I read. I am not shure how to properly<br>
change the spacing.<br><br>Best Regards!<br><font color="#888888"><br>Felix.<br></font><div><div></div><div class="Wj3C7c"><br><br><br><br><br>Quoting Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt;:<br>
<br>&gt; Felix,<br>&gt;<br>&gt; I just looked at the code in itkTIFFImageIO.cxx. We do in fact compute a<br>&gt; spacing on read if it exists. We don&#39;t write the spacing however.<br>&gt;<br>&gt; Here is the dilemma. TIFF supports units of measurement. Either inches,<br>
&gt; centimeters or none. In itk, we don&#39;t specify units although for medical<br>&gt; imaging they are usually mm&#39;s. At write time, we don&#39;t know what units to<br>&gt; specify. We could assume mm&#39;s and convert that to cm&#39;s I guess.<br>
&gt;<br>&gt; Bill<br>&gt; On Jan 24, 2008 11:08 AM, Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt;&gt; Felix,<br>&gt;&gt;<br>&gt;&gt; I don&#39;t believe that png supports spacing in the header. tiff might, but<br>
&gt;&gt; maybe we aren&#39;t writing the spacing. Can you file a bug following the<br>&gt;&gt; procedure in:<br>&gt;&gt;<br>&gt;&gt; <a href="http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes" target="_blank">http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes</a><br>
&gt;&gt;<br>&gt;&gt; Thanks,<br>&gt;&gt;<br>&gt;&gt; Bill<br>&gt;&gt; &nbsp; On Jan 24, 2008 10:49 AM, Felix Bollenbeck &lt;<a href="mailto:bollen@ipk-gatersleben.de">bollen@ipk-gatersleben.de</a>&gt;<br>&gt;&gt; wrote:<br>&gt;&gt;<br>
&gt;&gt; &gt; Hi ITK Users!<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; I&#39;m having troubles writing the spacing to a transformed image.<br>&gt;&gt; &gt; Although the resampler gets the input-image spacing, the written image<br>
&gt;&gt; &gt; which is read in the next iteration has the default [1 1] spacing<br>&gt;&gt; &gt; causing troubles.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; The images are written to tiff files and haven an initial spacing of<br>
&gt;&gt; &gt; .37... after transformation and writing, i read files with [1 1]<br>&gt;&gt; &gt; spacing, although<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; &nbsp;resample-&gt;SetOutputSpacing(fixedImage-&gt;GetSpacing());<br>&gt;&gt; &gt;<br>
&gt;&gt; &gt; and fixed image has [.37 .37]!<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; I have tried png files too, in case this is a TIF specific issue same-so<br>&gt;&gt; &gt; I conclude it is my mistake here, but where?<br>&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks for your help,<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; Felix.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; &nbsp;resample-&gt;SetSize( &nbsp; &nbsp;fixedImage-&gt;GetLargestPossibleRegion().GetSize()<br>
&gt;&gt; &gt; );<br>&gt;&gt; &gt; &nbsp;resample-&gt;SetOutputOrigin(fixedImage-&gt;GetOrigin());<br>&gt;&gt; &gt; &nbsp;resample-&gt;SetOutputSpacing(fixedImage-&gt;GetSpacing());<br>&gt;&gt; &gt; &nbsp;resample-&gt;SetDefaultPixelValue(0);<br>
&gt;&gt; &gt; &nbsp;resample-&gt;Update();<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; //#############<br>&gt;&gt; &gt; &nbsp;const SpacingType outSpacing = resample-&gt;GetOutputSpacing();<br>&gt;&gt; &gt; &nbsp;std::cout &lt;&lt;&quot;SIZE spacing-out &nbsp;&quot; &lt;&lt; outSpacing[0]&lt;&lt; &quot; &nbsp; &nbsp;&quot; &lt;&lt;<br>
&gt;&gt; &gt; outSpacing[1] &lt;&lt; std::endl;<br>&gt;&gt; &gt; //#############<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; &nbsp;typedef &nbsp;unsigned char &nbsp;OutputPixelType;<br>&gt;&gt; &gt; &nbsp;typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType;<br>
&gt;&gt; &gt; &nbsp;typedef itk::CastImageFilter&lt; FixedImageType,OutputImageType &gt;<br>&gt;&gt; &gt; CastFilterType;<br>&gt;&gt; &gt; &nbsp;typedef itk::ImageFileWriter&lt; OutputImageType &gt; &nbsp;WriterType;<br>&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>&gt;&gt; &gt; &nbsp;WriterType::Pointer &nbsp; &nbsp; &nbsp;writer = &nbsp;WriterType::New();<br>&gt;&gt; &gt; &nbsp;CastFilterType::Pointer &nbsp;caster = &nbsp;CastFilterType::New();<br>&gt;&gt; &gt; &nbsp;writer-&gt;SetFileName(outImageName);<br>
&gt;&gt; &gt; &nbsp;caster-&gt;SetInput(resample-&gt;GetOutput());<br>&gt;&gt; &gt; &nbsp;writer-&gt;SetInput(caster-&gt;GetOutput());<br>&gt;&gt; &gt; &nbsp;writer-&gt;Update();<br>&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Insight-users mailing list<br>&gt;&gt; &gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>&gt;&gt; &gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
&gt;&gt; &gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;<br><br><br><br>_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></div></blockquote></div><br>