[Insight-users] Converting and RGB image to grayscale
Michael Bell
michael.bell at acm.org
Tue Jun 7 17:46:12 EDT 2005
itk-users,
I am trying to convert an rgb image, stored as a uchar array, into a
grayscale image (VC++.net).
If I do the following, I get a deformed, but grayscale image (itk is
treating r,b, and b as separate pixels):
typedef itk::ImportImageFilter<PixelType,2> ImportFilterType;
ImportFilterType::Pointer importFilter = ImportFilterType::New();
...
importFilter->SetImportPointer(pixels,size,false);
outputImage = importFilter->GetOutput();
importFilter->Update();
If I try to filter the rgb into grayscale, I get compile errors:
typedef itk::ImportImageFilter<RGBPixel<unsigned char>,2>
ImportFilterType;
ImportFilterType::Pointer importFilter = ImportFilterType::New();
...
importFilter->SetImportPointer(pixels,size,false);
typedef itk::Image<RGBPixel<unsigned char>,2 > InputImageType;
typedef itk::Image<unsigned char,2> OutputImageType;
**typedef itk::RGBToLuminanceImageFilter<InputImageType,OutputImageType>
colorFilterType;
**ColorFilterType::Pointer colorFilter = ColorFilterType::New();
colorFilter->SetInput(importFilter->GetOutput());
...
The starred lines spawn these errors in itkRGBToLuminanceImageFilter:
TInput::ComponentType: cannot form a qualified name
ComponentType: is not a member of 'operator' global namespace
syntax error: missing ';' before identifier 'Component Type'
My model for this code is WatershedSegmentation1. Can anyone point out
my mistake with the luminance filter?
thanks,
michael
--
michael.bell at acm.org
More information about the Insight-users
mailing list