[Insight-users] A bug in itkAnalyzeImageIO?
Jian Wu
eewujian at yahoo.com
Thu Feb 7 14:25:45 EST 2008
Hi,
I'm doing image format conversion from other image types to Analyze 7.5. The program did not give me any error message. However I doubt it may not handle the image header information properly. The images I generated in Analyze 7.5 format can be viewed using MRIcro image viewer. But when I tried to opened it using Matlab function analyze75read, it gave me an error message "Reference to non-existent field 'ImgDataType'." I studies the ITK source code and found out the line 1128 of itkAnalyzeImageIO.cxx states:
switch( this->m_Hdr.dime.datatype)
Here "this->m_Hdr" has not been filled with proper image information yet when the input image is not in Analyze image format. I think "this->m_ComponentType" should be referred instead. My test code is attached here. I used "brainweb1e1a10f20.mha" as the input image.
Jian
Command line:
ImageReadWriteAnalyze brainweb1e1a10f20.mha brainweb1e1a10f20.img
Source Code:
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $ ImageReadWriteAnalyze.cxx $
Language: C++
Date: $Date: 2008/02/07 $
Version: $Revision: 1.0 $
Author: Jian Wu
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkAnalyzeImageIO.h"
#include "itkImage.h"
int main( int argc, char ** argv )
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;
return EXIT_FAILURE;
}
typedef unsigned short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
typedef itk::AnalyzeImageIO ImageIOType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
ImageIOType::Pointer analyzeIO = ImageIOType::New();
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
reader->SetFileName( inputFilename );
writer->SetFileName( outputFilename );
writer->SetInput( reader->GetOutput() );
writer->SetImageIO( analyzeIO );
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the Insight-users
mailing list