[Insight-users] Tif RGB wrong way around?

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Fri Jul 9 11:03:28 EDT 2004


After doing some digging I became convinced that there is nothing wrong with
the itk->vtk RGB pixels and so I tried exporting my TIFF as bmp using the
following code. The exported Bitmap has RGB components the wrong way around.

I'm therefore reasonably confident that the TIFF reader is messing about.

I'll modify my local version to give what I hope will be the correct images
and post a patch should anyone else have trouble.

JB


typedef itk::ImageFileReader< ImageTypeRGB2D > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
//
reader->SetFileName( filename );
//
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return NULL;
}
typedef itk::ImageFileWriter< ImageTypeRGB2D > WriterType;
WriterType::Pointer writer = WriterType::New();
//
writer->SetFileName("D:/Test.bmp");
writer->SetInput(reader->GetOutput());
writer->Update();
return reader->GetOutput();


----- Original Message ----- 
From: "John Biddiscombe" <jbiddiscombe at skippingmouse.co.uk>
To: "Julien Jomier" <jjomier at cs.unc.edu>; <insight-users at itk.org>
Sent: Thursday, July 08, 2004 6:59 PM
Subject: Re: [Insight-users] Tif RGB wrong way around?


> Thanks. I should have thought of trying that! I'll look for a mistake in
my
> code somewhere.
>
> JB
>
> ----- Original Message ----- 
> From: "Julien Jomier" <jjomier at cs.unc.edu>
> To: "'John Biddiscombe'" <jbiddiscombe at skippingmouse.co.uk>;
> <insight-users at itk.org>
> Sent: Thursday, July 08, 2004 6:47 PM
> Subject: RE: [Insight-users] Tif RGB wrong way around?
>
>
> Hi John,
>
> I just tried to read a RGB tiff image and write it as JPEG and BMP using
ITK
> and the resulting image appears to be valid so I guess the channels are in
> the correct order when reading the file.
>
> Hope this helps,
>
> Julien
>
> > -----Original Message-----
> > From: insight-users-bounces at itk.org
> > [mailto:insight-users-bounces at itk.org] On Behalf Of John Biddiscombe
> > Sent: Thursday, July 08, 2004 12:56 PM
> > To: insight-users at itk.org
> > Subject: [Insight-users] Tif RGB wrong way around?
> >
> >
> > I've connected itk::TiffImageIO to a vtk pipeline and found that when
> > reading RGB colour images the data looks as though its GBR
> > instead of RGB.
> > Red and blue channels swapped. I notice that the Tif test in
> > testing/code/io
> > uses a black and white image with R=G=B channels so this wouldn't be
> > spotted.
> >
> > Can anyone else easily check if TiffImageIO is getting R and
> > B the wrong way
> > around? It might be me passing the data into vtk, but since I'm using
> > SetImportVoidPointer directly and not modifying the actual
> > pixels, it should
> > be the same as when it was read.
> >
> > thanks
> >
> > JB
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
> _______________________________________________
> 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