[Insight-users] MetaImage Problems
Stephen R. Aylward
aylward at unc.edu
Wed Aug 4 15:10:46 EDT 2004
Hi,
Your program and MetaHeader file look correct! Congrats!
The problem is that MetaIO currently only supports data stored in raw
and compressed files. It doesn't currently support reading data from
PNG files. Sorry. It is a great idea for a new feature...
In the meantime, I recommend using ImageMagick to convert your .png
files to .raw files. ImageMagick has nice batch conversion
capabilities. Then your program and header should work.
Thanks,
Stephen
Jacob Boomgaarden wrote:
> Hi all,
>
> I am having problems with reading in a MetaImage into a
> quick example program.
>
> The code for my program is:
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
>
>
> int main(int argc, char ** argv)
> {
>
> typedef unsigned char PixelType;
> const unsigned int Dimension = 3;
>
> typedef itk::Image< PixelType, Dimension > ImageType;
>
> typedef itk::ImageFileReader< ImageType > ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> const char * inputfile = argv[1];
> reader->SetFileName( inputfile );
>
>
> // catch any errors
> try
> {
> reader->Update();
> }
> catch( itk::ExceptionObject &err )
> {
> std::cout<< "Exception Caught!"<< std::endl;
> std::cout<< err << std::endl;
> return 1;
> }
>
> ImageType::Pointer thoraxImage = reader->GetOutput();
> std::cout<<"All Done"<<std::endl;
> return 0;
> }
>
>
>
> I pass as a command line argument a metaimage header
> called "lungs.mhd" that looks like this:
>
> ObjectType = Image
> NDims = 3
> DimSize = 512 315 20
> ElementSpacing = 1 1 1
> Position = 0 0 0
> ElementByteOrderMSB = True
> ElementType = MET_UCHAR
> ElementDataFile = lungs.%03d 0 19 1
>
> The images that make up the MetaImage are all PNG images
> of 63.5 KB with size 512 X 315 and data type unsigned char.
>
> The error messages I'm getting are:
>
> file = _lungs.000_
> MetaImage: M_ReadElements: data not read completely
> ideal = 161280 : actual = 0
>
> over the twenty images that I give it.
>
> Thanks for the help.
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
--
===========================================================
Dr. Stephen R. Aylward
Associate Professor of Radiology
Adjunct Associate Professor of Computer Science and Surgery
http://caddlab.rad.unc.edu
aylward at unc.edu
(919) 966-9695
More information about the Insight-users
mailing list