[Insight-users] PLEASE HELP! 48 bit to 24 bit RGB Image conversion
John Eke
johne at annidis.com
Fri Jun 6 03:57:41 EDT 2008
Hi,
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
Thanks
John
--------------------------------------------------------------------------
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkResampleImageFilter.h"
#include "itkLinearInterpolateImageFunction.h"
#include "vtkImageActor.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "itkSimilarity2DTransform.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkCamera.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "itkVectorResampleImageFilter.h"
#include "itkSimilarity2DTransform.h"
#include "itkRGBPixel.h"
#include "itkVector.h"
#include "vtkRenderWindow.h"
#include "itkVectorRescaleIntensityImageFilter.h"
#include "itkVectorInterpolateImageFunction.h"
int main( int argc, char * argv[] )
{
if (argc < 2)
{
cout<<"Please enter filename for a picture\n";
return 0;
}
const unsigned int Dimmension = 2;
typedef itk::Vector<unsigned short> InputPixelType;
typedef itk::RGBPixel<unsigned char> OutputPixelType;
typedef itk::Image<InputPixelType, Dimmension> InputImageType;
typedef itk::Image<OutputPixelType, Dimmension> OutputImageType;
typedef itk::ImageFileReader<InputImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
typedef itk::ImageFileWriter<OutputImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("convertedfile.png");
typedef itk::VectorRescaleIntensityImageFilter<InputImageType, OutputImageType> RescaleFilterType;
RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
rescaleFilter->SetInput(reader->GetOutput());
writer->SetInput(rescaleFilter->GetOutput());
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return 0;
}
cout<<"PROCESSING PASSED!"<<endl;
return 0;
}
-----Original Message-----
From: Bill Lorensen [mailto:bill.lorensen at gmail.com]
Sent: Thu 6/5/2008 3:43 PM
To: John Eke
Cc: insight-users at itk.org
Subject: Re: [Insight-users] PLEASE HELP! RescaleIntensityImageFilter and Non Scalar Images
try itkVectorRescaleIntensityImageFilter
On Thu, Jun 5, 2008 at 2:45 PM, John Eke <johne at annidis.com> wrote:
> Hi,
>
> Could someone please show me how to read use the RescaleIntensityImageFilter
> with RGB Images? When I set an RGB image type (of type itk::RGBPixel<short
> unsigned int>) as input, I get lots of very confusing errors upon
> initializing the object:
>
> const unsigned int Dimmension = 2;
> typedef itk::RGBPixel<short unsigned int> InputPixelType;
> typedef itk::RGBPixel<unsigned char> OutputPixelType;
>
> typedef itk::Image<InputPixelType, Dimmension> InputImageType;
> typedef itk::Image<OutputPixelType, Dimmension> OutputImageType;
>
> typedef itk::ImageFileReader<InputImageType> ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> reader->SetFileName(path.toStdString().c_str());
> typedef itk::RescaleIntensityImageFilter<InputImageType,
> OutputImageType> FilterType;
> FilterType::Pointer filter = FilterType::New(); //ERROR OCCURS HERE
>
> What am I not doing right?
>
> Thanks
>
> John
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080606/2e798d3b/attachment-0001.htm>
More information about the Insight-users
mailing list