[Insight-users] cannot read a tiff image

bear xgl99 at mails.tsinghua.edu.cn
Wed Jan 5 21:58:41 EST 2005


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;

}




More information about the Insight-users mailing list