[Insight-users] writing a png file

gwenael.guillard@enst-bretagne.fr gwenael . guillard at enst-bretagne . fr
Wed, 25 Jun 2003 15:43:47 +0200


Hi ITK users,

I'm trying to write a png file from an image. It's writing a file with the 
right number of rows and columns but empty, ie black. Here is the code I'm 
using. DId I forget smthg? The imageViewer part is to be sure the image isn't 
black (and it is not)


	PNGType::Pointer imageIO = PNGType::New();
	
	ImageWriterType::Pointer writer = ImageWriterType::New();
	writer->SetImageIO( imageIO );
	writer->SetFileName( baseFilename );
 

	writer->SetInput( m_Output ); // m_Output is the image to write
	writer->Write();

	ImageViewerType::Pointer imageViewer = ImageViewerType::New();
	imageViewer->SetLabel("Output Image");
	imageViewer->SetImage( m_Output );
	imageViewer->Show();


Thank you for your help,

Gwen