<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [Insight-users] PLEASE HELP! 48 bit to 24 bit RGB Image conversion</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hi,<BR>
<BR>
I figured out that the itkVectorRescaleIntensityImageFilter requires a Vector as input, but for the output I could use my target which was an RGBPixel. Problem now though, the converted image comes out all black. Am I forgetting to set something? please look at the code below (it will run as is). All I want to do (as is obvious from the code below) is to convert a 48 bit RGB image to a 24 bit RGB image. The code below works, but the resulting image is pitch black. Please help any way you can<BR>
<BR>
Thanks<BR>
<BR>
John<BR>
--------------------------------------------------------------------------<BR>
<BR>
#include "itkImage.h"<BR>
#include "itkImageFileReader.h"<BR>
#include "itkImageFileWriter.h"<BR>
#include "itkResampleImageFilter.h"<BR>
#include "itkLinearInterpolateImageFunction.h"<BR>
#include "vtkImageActor.h"<BR>
#include "vtkRenderWindowInteractor.h"<BR>
#include "vtkRenderWindow.h"<BR>
#include "vtkRenderer.h"<BR>
#include "itkSimilarity2DTransform.h"<BR>
#include "itkImageToVTKImageFilter.h"<BR>
#include "vtkCamera.h"<BR>
#include "itkImage.h"<BR>
#include "itkImageFileReader.h"<BR>
#include "itkImageToVTKImageFilter.h"<BR>
#include "itkVectorResampleImageFilter.h"<BR>
#include "itkSimilarity2DTransform.h"<BR>
#include "itkRGBPixel.h"<BR>
#include "itkVector.h"<BR>
#include "vtkRenderWindow.h"<BR>
#include "itkVectorRescaleIntensityImageFilter.h"<BR>
#include "itkVectorInterpolateImageFunction.h"<BR>
<BR>
<BR>
int main( int argc, char * argv[] )<BR>
{<BR>
if (argc < 2)<BR>
{<BR>
cout<<"Please enter filename for a picture\n";<BR>
return 0;<BR>
}<BR>
const unsigned int Dimmension = 2;<BR>
typedef itk::Vector<unsigned short> InputPixelType;<BR>
typedef itk::RGBPixel<unsigned char> OutputPixelType;<BR>
<BR>
typedef itk::Image<InputPixelType, Dimmension> InputImageType;<BR>
typedef itk::Image<OutputPixelType, Dimmension> OutputImageType;<BR>
<BR>
typedef itk::ImageFileReader<InputImageType> ReaderType;<BR>
ReaderType::Pointer reader = ReaderType::New();<BR>
reader->SetFileName(argv[1]);<BR>
<BR>
typedef itk::ImageFileWriter<OutputImageType> WriterType;<BR>
WriterType::Pointer writer = WriterType::New();<BR>
writer->SetFileName("convertedfile.png");<BR>
<BR>
typedef itk::VectorRescaleIntensityImageFilter<InputImageType, OutputImageType> RescaleFilterType;<BR>
RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();<BR>
<BR>
rescaleFilter->SetInput(reader->GetOutput());<BR>
writer->SetInput(rescaleFilter->GetOutput());<BR>
<BR>
try<BR>
{<BR>
writer->Update();<BR>
}<BR>
catch( itk::ExceptionObject & err )<BR>
{<BR>
std::cerr << "ExceptionObject caught !" << std::endl;<BR>
std::cerr << err << std::endl;<BR>
return 0;<BR>
}<BR>
cout<<"PROCESSING PASSED!"<<endl; <BR>
return 0;<BR>
}<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: Bill Lorensen [<A HREF="mailto:bill.lorensen@gmail.com">mailto:bill.lorensen@gmail.com</A>]<BR>
Sent: Thu 6/5/2008 3:43 PM<BR>
To: John Eke<BR>
Cc: insight-users@itk.org<BR>
Subject: Re: [Insight-users] PLEASE HELP! RescaleIntensityImageFilter and Non Scalar Images<BR>
<BR>
try itkVectorRescaleIntensityImageFilter<BR>
<BR>
On Thu, Jun 5, 2008 at 2:45 PM, John Eke <johne@annidis.com> wrote:<BR>
> Hi,<BR>
><BR>
> Could someone please show me how to read use the RescaleIntensityImageFilter<BR>
> with RGB Images? When I set an RGB image type (of type itk::RGBPixel<short<BR>
> unsigned int>) as input, I get lots of very confusing errors upon<BR>
> initializing the object:<BR>
><BR>
> const unsigned int Dimmension = 2;<BR>
> typedef itk::RGBPixel<short unsigned int> InputPixelType;<BR>
> typedef itk::RGBPixel<unsigned char> OutputPixelType;<BR>
><BR>
> typedef itk::Image<InputPixelType, Dimmension> InputImageType;<BR>
> typedef itk::Image<OutputPixelType, Dimmension> OutputImageType;<BR>
><BR>
> typedef itk::ImageFileReader<InputImageType> ReaderType;<BR>
><BR>
> ReaderType::Pointer reader = ReaderType::New();<BR>
><BR>
> reader->SetFileName(path.toStdString().c_str());<BR>
> typedef itk::RescaleIntensityImageFilter<InputImageType,<BR>
> OutputImageType> FilterType;<BR>
> FilterType::Pointer filter = FilterType::New(); //ERROR OCCURS HERE<BR>
><BR>
> What am I not doing right?<BR>
><BR>
> Thanks<BR>
><BR>
> John<BR>
> _______________________________________________<BR>
> Insight-users mailing list<BR>
> Insight-users@itk.org<BR>
> <A HREF="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</A><BR>
><BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>