[Insight-users] Problem on writting Meta Image

Luis Ibanez luis . ibanez at kitware . com
Thu, 06 Nov 2003 21:45:47 -0500


Hi Fucang,

Thanks for your detailed report.

Julien Jomier fixed this about two hours ago  :-)

http://www . itk . org/cgi-bin/viewcvs . cgi/Utilities/MetaIO/metaImage . cxx?sortby=date&cvsroot=Insight


You will have to obtain the CVS version in order
get the fixes.

or, you could simply update the file:

         Utilities/MetaIO/metaImage.cxx

Please let us know if you find further problems


   Thanks

     Luis


-----------------
Fucang Jia wrote:
> Hi everyone,
> 
> Recently when I use ITK 1.4 to write a series of file filtered using 
> only one writer,  if the written file is Meta Image format, the latter 
> file name will overwrite the former. For example:
> 
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNormalizeImageFilter.h"
> #include "itkMeanImageFilter.h"
> 
> int main( int argc, char ** argv )
> {
> 
>  if( argc < 4 )
>    {
>    std::cerr << "Usage: " <<argv[0]
>              << " Input2D OutputNormImageName OutputMeanImageName"
>              << std::endl;
>    return -1;
>    }
> 
> 
>  typedef float               PixelType;
>  const   unsigned int        Dimension = 2;
> 
>  typedef itk::Image< PixelType, Dimension >    ImageType;
> 
>  typedef itk::ImageFileReader< ImageType >  ReaderType;
>  typedef itk::ImageFileWriter< ImageType >  WriterType;
>  typedef itk::NormalizeImageFilter< ImageType, ImageType> NormType;
>  typedef itk::MeanImageFilter< ImageType, ImageType >     MeanType;
> 
> 
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
>  NormType::Pointer normfilter = NormType::New();
>  MeanType::Pointer meanfilter = MeanType::New();
> 
>  reader->SetFileName( argv[1]  );
> 
>  normfilter->SetInput(reader->GetOutput());
> 
>  writer->SetFileName( argv[2] );
>  writer->SetInput( normfilter->GetOutput() );
>  writer->Update();
> 
>  ImageType::SizeType neighRadius;
>  neighRadius[0] = 1;
>  neighRadius[1] = 1;
> 
>  meanfilter->SetRadius(neighRadius);
>  meanfilter->SetInput(reader->GetOutput());
> 
>  writer->SetFileName( argv[3] );
>  writer->SetInput( meanfilter->GetOutput() );
>  writer->Update();
> 
>  return 0;
> }
> 
> If I use this program and want output norm.mhd and mean.mhd
> it write norm.mhd and norm.raw at first (this is right)
> and it should write mean.mhd and mean.raw, but the mean.raw not written, 
> the norm.raw was overwritten. The mean.mhd is as follows:
> 
> ObjectType = Image
> NDims = 2
> BinaryData = True
> BinaryDataByteOrderMSB = True
> DimSize = 512 512
> ElementSize = 1 1
> ElementType = MET_FLOAT
> ElementDataFile = norm.raw
> 
> This problem does not occur when the output file is Analyze format , 
> norm.hdr, norm.img, mean.hdr and mean.img are written in the right way.
> 
> AnisotropicDiffusionFltkGui2D and AnisotropicDiffusionFltkGui3D should 
> replicate this problem.
> 
> Fucang
>