[Insight-developers] ImageAdaptors and RGB images
Richard Beare
richard.beare at gmail.com
Mon Feb 21 18:08:46 EST 2011
Hi,
I'm trying to take a difference between channels of an RGB image. The
color accessor functors seem the appropriate way of doing it, but I'm
running into problems with concept checks in the subtract filter.
Am I making a stupid error with this code? Should I be using an
alternative approach?
Thanks
typedef typename itk::Image<pixtype, dim> RawImType;
typedef typename itk::Image<unsigned char, dim> MaskImType;
typedef typename itk::Image<short, dim> SignedImType;
typedef itk::RGBPixel<pixtype> RGBPixelType;
typedef itk::Image<RGBPixelType, dim> RGBImageType;
typename RGBImageType::Pointer raw = readIm<RGBImageType>(CmdLineObj.InputIm);
typedef typename itk::RedPixelAccessor<RGBPixelType> RedAccessorType;
typedef typename itk::GreenPixelAccessor<RGBPixelType> GreenAccessorType;
typedef typename itk::BluePixelAccessor<RGBPixelType> BlueAccessorType;
typedef typename itk::ImageAdaptor<RGBImageType, RedAccessorType>
RedAdaptorType;
typedef typename itk::ImageAdaptor<RGBImageType, GreenAccessorType>
GreenAdaptorType;
typedef typename itk::ImageAdaptor<RGBImageType, BlueAccessorType>
BlueAdaptorType;
typename RedAdaptorType::Pointer RedAdaptor = RedAdaptorType::New();
typename GreenAdaptorType::Pointer GreenAdaptor = GreenAdaptorType::New();
typename BlueAdaptorType::Pointer BlueAdaptor = BlueAdaptorType::New();
RedAdaptor->SetImage(raw);
GreenAdaptor->SetImage(raw);
BlueAdaptor->SetImage(raw);
// blue - red selects cyan
// red - blue selects yellow
itk::Instance< itk::SubtractImageFilter< BlueAdaptorType,
RedAdaptorType, SignedImType> > Difference;
Difference->SetInput(BlueAdaptor);
Difference->SetInput2(RedAdaptor);
More information about the Insight-developers
mailing list