[Insight-users] change spacing of a mhd file

John Drescher drescherjm at gmail.com
Mon Jun 28 15:09:55 EDT 2010


On Mon, Jun 28, 2010 at 3:05 PM, jbehar <jbehar at messel.emse.fr> wrote:
>
> Hi all,
>
> I am trying to convert a stack of png into a .mhd file. The stack is the
> result of a segmentation process and I would like, when writing the .mhd, to
> specify the spacing. I tried to do it by creating an intermediate image and
> using  ImageType::SpacingType spacing. It seems to work when I use
> image->GetSpacing() like this:
>  const ImageType::SpacingType& sp = image->GetSpacing();
>  std::cout << "Spacing =";
>  std::cout << sp[0] << ","<<sp[1] << "," << sp[2] << std::endl;
>
> it prints the correct answer but when I write the file as a .mhd
>  writer->SetInput( image);
>  writer->SetFileName( outputFilename );
> and open the .mhd file, the spacing is not changed.
>
> If you have a clue...
>
Use the itkChangeInformationImageFilter to change the spacing, origin ...

John


More information about the Insight-users mailing list