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, <<a href="mailto:bollen@ipk-gatersleben.de">bollen@ipk-gatersleben.de</a>> 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->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 <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>>:<br>
<br>> Felix,<br>><br>> I just looked at the code in itkTIFFImageIO.cxx. We do in fact compute a<br>> spacing on read if it exists. We don't write the spacing however.<br>><br>> Here is the dilemma. TIFF supports units of measurement. Either inches,<br>
> centimeters or none. In itk, we don't specify units although for medical<br>> imaging they are usually mm's. At write time, we don't know what units to<br>> specify. We could assume mm's and convert that to cm's I guess.<br>
><br>> Bill<br>> On Jan 24, 2008 11:08 AM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>><br>>> Felix,<br>>><br>>> I don't believe that png supports spacing in the header. tiff might, but<br>
>> maybe we aren't writing the spacing. Can you file a bug following the<br>>> procedure in:<br>>><br>>> <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>
>><br>>> Thanks,<br>>><br>>> Bill<br>>> On Jan 24, 2008 10:49 AM, Felix Bollenbeck <<a href="mailto:bollen@ipk-gatersleben.de">bollen@ipk-gatersleben.de</a>><br>>> wrote:<br>>><br>
>> > 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>
>> > );<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">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>
>> ><br>>><br>>><br>><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>