[Insight-users] problem with RGB .bmp images
John
dbgtjp at hotmail.com
Wed Sep 24 07:11:55 EDT 2008
I'm getting .bmp files from an OCT device, which I segment then on converted
greyscale images.
The problem is, that I would like to apply the segmented borders to the original
colored images. But I can't even read the files in color format.
The below code doesn't work with the .bmp images from the OCT device, but with
other .bmp or rgb images such as jpeg, png the code works.
What could that be? Really mysterious.
Thanks in advance for any help.
John
//RGBTest.cxx
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
#include "itkRGBPixel.h"
int main( int argc, char ** argv )
{
typedef itk::RGBPixel< unsigned char > PixelType;
const unsigned int Dimension = 2;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
reader->SetFileName(inputFilename);
writer->SetFileName(outputFilename);
writer->SetInput( reader->GetOutput() );
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
//CMakeLists.txt
PROJECT(RGBTest)
# Find ITK.
FIND_PACKAGE(ITK REQUIRED)
IF(ITK_FOUND)
INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)
ADD_EXECUTABLE(RGBTest RGBTest.cxx )
TARGET_LINK_LIBRARIES(RGBTest ITKCommon ITKIO)
More information about the Insight-users
mailing list