<div>Felix,</div>
<div> </div>
<div>I just looked at the code in itkTIFFImageIO.cxx. We do in fact compute a spacing on read if it exists. We don't write the spacing however.</div>
<div> </div>
<div>Here is the dilemma. TIFF supports units of measurement. Either inches, centimeters or none. In itk, we don't specify units although for medical imaging they are usually mm's. At write time, we don't know what units to specify. We could assume mm's and convert that to cm's I guess.</div>
<div> </div>
<div>Bill<br></div>
<div class="gmail_quote">On Jan 24, 2008 11:08 AM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Felix,</div>
<div> </div>
<div>I don't believe that png supports spacing in the header. tiff might, but maybe we aren't writing the spacing. Can you file a bug following the procedure in:</div>
<div> </div>
<div><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></div>
<div> </div>
<div>Thanks,</div><font color="#888888">
<div> </div>
<div>Bill<br></div></font>
<div>
<div></div>
<div class="Wj3C7c">
<div class="gmail_quote">On Jan 24, 2008 10:49 AM, Felix Bollenbeck <<a href="mailto:bollen@ipk-gatersleben.de" target="_blank">bollen@ipk-gatersleben.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi ITK Users!<br><br>I'm having troubles writing the spacing to a transformed image.<br>Although the resampler gets the input-image spacing, the written image<br>
which is read in the next iteration has the default [1 1] spacing<br>causing troubles.<br><br>The images are written to tiff files and haven an initial spacing of<br>.37... after transformation and writing, i read files with [1 1]<br>
spacing, although<br><br> resample->SetOutputSpacing(fixedImage->GetSpacing());<br><br>and fixed image has [.37 .37]!<br><br>I have tried png files too, in case this is a TIF specific issue same-so<br>I conclude it is my mistake here, but where?<br>
<br>Thanks for your help,<br><br>Felix.<br><br><br><br><br><br><br> resample->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );<br> resample->SetOutputOrigin(fixedImage->GetOrigin());<br> resample->SetOutputSpacing(fixedImage->GetSpacing());<br>
resample->SetDefaultPixelValue(0);<br> resample->Update();<br><br>//#############<br> const SpacingType outSpacing = resample->GetOutputSpacing();<br> std::cout <<"SIZE spacing-out " << outSpacing[0]<< " " <<<br>
outSpacing[1] << std::endl;<br>//#############<br><br><br> typedef unsigned char OutputPixelType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br> typedef itk::CastImageFilter< FixedImageType,OutputImageType ><br>
CastFilterType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br><br> WriterType::Pointer writer = WriterType::New();<br> CastFilterType::Pointer caster = CastFilterType::New();<br> writer->SetFileName(outImageName);<br>
caster->SetInput(resample->GetOutput());<br> writer->SetInput(caster->GetOutput());<br> writer->Update();<br>_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org" target="_blank">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></blockquote></div><br></div></div></blockquote></div><br>