[Insight-users] Working with RescaleIntensityImageFilter in XCode
Rupinder Singh
rupinder.singh123 at yahoo.com
Tue Nov 1 01:03:23 EDT 2011
I'm having difficulty understanding why the following function throws an
exception at 'writer->Update()' whenever it's called.
const unsigned int Dimension = 2;
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
void saveITKImage(InputImageType *image)
{
typedef itk::RescaleIntensityImageFilter< InputImageType,
OutputImageType > CastFilterType;
typedef itk::ImageFileWriter< InputImageType >
WriterType;
WriterType::Pointer writer = WriterType::New();
CastFilterType::Pointer caster = CastFilterType::New();
writer->SetFileName("/Users/usr/Desktop/test.jpg");
caster->SetOutputMinimum( 0 );
caster->SetOutputMaximum( 255 );
// Define Pipeline
caster->SetInput( image );
writer->SetInput( caster->GetOutput() );
writer->Update();
return;
}
I know I'm doing something right because the following bit of code works perfectly when called.
void saveITKImage(InputImageType *image)
{
typedef itk::ImageFileWriter< InputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("/Users/usr/Desktop/test.jpg");
// Define Pipeline
writer->SetInput( image);
writer->Update();
return;
}
Does anyone know what I'm doing wrong?
Thank you in advance for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111101/26faf061/attachment.htm>
More information about the Insight-users
mailing list