[Insight-users] Converting and RGB image to grayscale

Michael Bell michael.bell at acm.org
Wed Jun 8 10:27:42 EDT 2005


A kind user pointed me to the RGBToGrayscale example, where I saw that I
had a typo in my image types.


thanks,
michael

On Tue, 07 Jun 2005 16:46:12 -0500, "Michael Bell"
<michael.bell at acm.org> said:
> 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
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
--
michael.bell at acm.org



More information about the Insight-users mailing list