[Insight-users] using itkLabelOverlayImageFilter

john smith mkitkinsightuser at gmail.com
Wed Jun 29 15:34:35 EDT 2011


Could somebody explain what exactly do itkLabelOverlayImageFilter?  I have
written the following code but still I get this error
* error C2296: '%' : illegal, left operand has type 'const float'
*
I hope somebody could help.
Thanks*

////////////////code/////////////////////
*
*  typedef   float           InternalPixelType;
  const     unsigned int    Dimension = 2;
  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
  typedef  itk::ImageFileReader< InternalImageType > ReaderType;*
*
 ReaderType::Pointer reader1 = ReaderType::New();
    reader1->SetFileName( fileName.toStdString()  );
    reader1->Update();

   InternalImageType::Pointer image1 = reader1->GetOutput();


   ReaderType::Pointer reader2 = ReaderType::New();
   reader2->SetFileName( "result.png"  );
   reader2->Update();

   InternalImageType::Pointer image2 = reader2->GetOutput();

   typedef itk::RGBPixel<unsigned char> RGBPixelType;
  typedef itk::Image<RGBPixelType> RGBImageType;

 typedef itk::LabelOverlayImageFilter<InternalImageType, InternalImageType,
RGBImageType> LabelOverlayFilterType;
  LabelOverlayFilterType::Pointer labelOverlayFilter =
LabelOverlayFilterType::New();
  labelOverlayFilter->SetInput(image1);
  labelOverlayFilter->SetLabelImage(image2);
  labelOverlayFilter->SetOpacity(1.0);
  labelOverlayFilter->ResetColors(); // reset color map
  labelOverlayFilter->AddColor(0, 0, 255); // fill color map with blue
  labelOverlayFilter->SetBackgroundValue(0); // don't overlay the
background, i.e., label 0
  labelOverlayFilter->Update();

  typedef  itk::ImageFileWriter< RGBImageType  > WriterType_RGB;
  WriterType_RGB::Pointer writer_RGB = WriterType_RGB::New();
  writer_RGB->SetFileName("addImage.png");
  writer_RGB->SetInput(labelOverlayFilter->GetOutput());
  writer_RGB->Update();*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110629/0124b6ce/attachment.htm>


More information about the Insight-users mailing list