[Insight-users] cannot read a tiff image

bear xgl99 at mails.tsinghua.edu.cn
Thu Jan 6 20:42:30 EST 2005


hi Luis,
   As you suggest, I add try/catch code, and show that Abort message is indeed
raised by JpegIO:
   
ExceptionObject caught !

itk::ExceptionObject (0x80f3b28)
Location: "Unknown"
File: /home/src/Insight/Code/IO/itkJPEGImageIO.cxx
Line: 404
Description: itk::ERROR: JPEGImageIO(0x80f3cc8): JPEG supports unsigned char/int
only

This exception does not appear when saving in bmp or png. However, The result
is a completely *black* image which is wrong. I see cells in Matlab.
Are you sure TIFF file is already loaded accurately? 

                                                                Regards
                                                                 bear
>From: Luis Ibanez <luis.ibanez at kitware.com>
>Reply-To: 
>To: bear <xgl99 at mails.tsinghua.edu.cn>
>Subject: Re: [Insight-users] cannot read a tiff image
>
>
> Hi Bear,
> 
> 
> Your file
> 
>    http://166.111.201.234/w1.tiff
> 
> is a non standard TIFF file.
> 
> The "identify" tool from ImageMagick reports the following:
> 
> w1.tiff TIFF 1280x1024+0+0 PseudoClass 65536c 16-bit 2.5m 0.050u 0:01
> 
> e:\program files\imagemagick-5.5.5-q16\identify.exe:
> 
> unknown field with tag 33628 (0x835c) encountered. (w1.tiff).
> 
> 
> 
> Note however that ITK read it fine.
> 
> You get the warnings,..
> but the image is read from the file without problem.
> 
> 
> The Abort message that you are receiving is probably produced
> by the writer->Update(). This commonly happens if you provide
> an output filename that doesn't correspond to a fileformat
> recognized by ITK.
> 
> What *exact* filename did you used for the output ?
> 
> 
> For a simple verification, just add try/catch blocks around
> the Update() calls of both the reader and the writer.
> 
> Chances are that you will see the reader passing fine, and
> the writer aborting.
> 
> For a list of the image fileformats supported in ITK, please
> look at the FAQ
> 
>          http://www.itk.org/Wiki/ITK_FAQ
> 
> 
> 
> 
> Regards,
> 
> 
>     Luis
> 
> 
> 
> ----------------
> bear wrote:
> 
> > hi itk-users,
> >        I have a tiff image(http://166.111.201.234/w1.tiff) which can be read
by
> > Matlab's imread() function, but it cannot be read by itk with errors:
> > 
> > w1.tiff: Warning, unknown field with tag 317 (0x13d) ignored.
> > w1.tiff: Warning, unknown field with tag 33628 (0x835c) ignored.
> > Aborted
> > What is the problem then? Thanks!
> > 
> > 
> > The code:
> > 
> > #include "itkImageFileReader.h"
> > #include "itkImageFileWriter.h"
> > #include "itkImage.h"
> > #include "itkRescaleIntensityImageFilter.h"
> > int main(int ac, char* av[])
> > {
> > 	if(ac < 3)
> >     {  
> > 		std::cerr << "Usage: " << av[0] << " input output\n";
> > 		return 1;
> >     }
> > 	typedef unsigned short InputPixelType;
> > 	typedef itk::Image< InputPixelType, 2 > InputImageType;
> > 	typedef itk::ImageFileReader< InputImageType > ReaderType;
> > 	ReaderType::Pointer reader = ReaderType::New();
> > 	reader->SetFileName( av[1] );
> > 
> > 	reader->Update();
> > 
> > 	typedef unsigned char WritePixelType;
> > 	typedef itk::Image< WritePixelType, 2 > WriteImageType;
> > 	typedef itk::RescaleIntensityImageFilter<
> > 		InputImageType, WriteImageType > RescaleFilterType;
> > 
> > 	RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
> > 	rescaler->SetOutputMinimum(   0 );
> > 	rescaler->SetOutputMaximum( 255 );
> > 	typedef itk::ImageFileWriter< WriteImageType >  WriterType;
> > 
> > 	WriterType::Pointer writer = WriterType::New();
> > 
> > 	writer->SetFileName( av[2] );
> > 
> > 	rescaler->SetInput( reader->GetOutput() );
> > 	writer->SetInput( rescaler->GetOutput() );
> > 
> > 	writer->Update();
> > 	return 0;
> > 
> > }
> > 
> > 
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> > 
> > 
> 
> 
> 
> 
>




More information about the Insight-users mailing list