[Insight-users] bmp read write
medamine
miladimedamine at yahoo.fr
Wed Mar 21 07:59:09 EST 2007
hi,
I would like to read and write bmp image;but it lost her color and for other
image it become black.
thank;
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include <list>
#include <fstream>
typedef itk::RGBPixel<unsigned char > InternalPixelType;
typedef itk::Image< InternalPixelType, 2 > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::RescaleIntensityImageFilter< ImageType, ImageType >
RescaleFilterType;
typedef itk::Image< InternalPixelType, 2 > WriteImageType;
typedef itk::ImageFileWriter< WriteImageType > WriterType;
int main( int argc, char* argv[] )
{
/*********LECTURE****************/
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName("test.bmp");
try
{
reader->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "error " << excp << std::endl;
return;
}
//ImageType::ConstPointer image = reader->GetOutput();
/*********ECRITURE****************/
//typedef itk::Image< unsigned char, 2 > WriteImageType;
//typedef itk::ImageFileWriter< WriteImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( "resultat.bmp" );
writer->SetInput(reader->GetOutput());
try
{
writer->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
}
--
View this message in context: http://www.nabble.com/bmp-read-write-tf3440507.html#a9593352
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list