[Insight-users] setSpacing() Ignored writing to files

Bill Lorensen bill.lorensen at gmail.com
Thu Jan 24 11:08:58 EST 2008


Felix,

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:

http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes

Thanks,

Bill
On Jan 24, 2008 10:49 AM, Felix Bollenbeck <bollen at ipk-gatersleben.de>
wrote:

> Hi ITK Users!
>
> I'm having troubles writing the spacing to a transformed image.
> Although the resampler gets the input-image spacing, the written image
> which is read in the next iteration has the default [1 1] spacing
> causing troubles.
>
> The images are written to tiff files and haven an initial spacing of
> .37... after transformation and writing, i read files with [1 1]
> spacing, although
>
>  resample->SetOutputSpacing(fixedImage->GetSpacing());
>
> and fixed image has [.37 .37]!
>
> I have tried png files too, in case this is a TIF specific issue same-so
> I conclude it is my mistake here, but where?
>
> Thanks for your help,
>
> Felix.
>
>
>
>
>
>
>  resample->SetSize(    fixedImage->GetLargestPossibleRegion().GetSize() );
>  resample->SetOutputOrigin(fixedImage->GetOrigin());
>  resample->SetOutputSpacing(fixedImage->GetSpacing());
>  resample->SetDefaultPixelValue(0);
>  resample->Update();
>
> //#############
>  const SpacingType outSpacing = resample->GetOutputSpacing();
>  std::cout <<"SIZE spacing-out  " << outSpacing[0]<< "    " <<
> outSpacing[1] << std::endl;
> //#############
>
>
>  typedef  unsigned char  OutputPixelType;
>  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>  typedef itk::CastImageFilter< FixedImageType,OutputImageType >
> CastFilterType;
>  typedef itk::ImageFileWriter< OutputImageType >  WriterType;
>
>
>  WriterType::Pointer      writer =  WriterType::New();
>  CastFilterType::Pointer  caster =  CastFilterType::New();
>  writer->SetFileName(outImageName);
>  caster->SetInput(resample->GetOutput());
>  writer->SetInput(caster->GetOutput());
>  writer->Update();
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080124/0772ae6b/attachment.html


More information about the Insight-users mailing list