[Insight-users] Problem on writting Meta Image
Fucang Jia
jiafucang at hotmail . com
Fri, 07 Nov 2003 10:13:09 +0800
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
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join . msn . com/?page=features/junkmail