[vtkusers] Coloured Binary Segmentation Overlay

Honkey Tonk markenjodsalz at gmx.net
Thu Sep 8 10:50:10 EDT 2011


Hi, I have only been working with VTK and ITK for a month now. The mailing list has helped me a lot, but at the moment I'm stuck. 

The first problem:
I have 12-bit grayscale input and a binary segmentation of that input. I use ImageBlend to show an overlay in a single ImageViewer2. It worked until I tried to color the segmentation,  using a LookupTable and ImageMapToColors. This results in an error: "vtkImageBlend (0x167d040): input has too many components, can't blend RGB data into greyscale data". 
Someone posted a solution: Map the input image to grayscale using a second LUT. This works; however, its effect seems to be to crop the image range to 8bit, which is undesirable. Is there another way to get rid of the error? 

The second problem: 
The binary segmentation does appear in red, but as soon as I change a window or level value of the ImageViewer2, it changes to grayscale. I haven't been able to find a solution for this yet.

Thanks a lot for any help!
Falk

**************************************************
Corresponding code:

//LUT for coloured labels
  lookupTable = vtkSmartPointer<vtkLookupTable>::New();
  lookupTable->SetNumberOfTableValues(2);
  lookupTable->SetRange(0,m_ImageRange[1]);
  lookupTable->SetTableValue( 0, 0.0, 0.0, 0.0, 0.0 ); //label 0 is transparent
  lookupTable->SetTableValue( 1, 1.0, 0.0, 0.0, 1.0 ); //label 1 is opaque and red
  lookupTable->Build();

  mapColor = vtkSmartPointer<vtkImageMapToColors>::New();
  mapColor->SetLookupTable(lookupTable);
  mapColor->SetInput(threshold->GetOutput());
  mapColor->PassAlphaToOutputOn();

    //map input image for use with imageblend
    vtkSmartPointer<vtkLookupTable> lookupTable2 =
      vtkSmartPointer<vtkLookupTable>::New();
    lookupTable2->SetSaturationRange(0,0);
    lookupTable2->SetValueRange(0,1);
    lookupTable2->SetHueRange(0,0);
    lookupTable2->SetTableRange(1,100);
    lookupTable2->Build();

    vtkSmartPointer<vtkImageMapToColors> mapColor2 =
      vtkSmartPointer<vtkImageMapToColors>::New();
    mapColor2->SetLookupTable(lookupTable2);
    mapColor2->SetInput(m_vtkInputImage);
    mapColor2->PassAlphaToOutputOn();

  //blend images
  blend = vtkSmartPointer<vtkImageBlend>::New();
  blend->AddInput(mapColor2->GetOutput());
  blend->AddInput(mapColor->GetOutput());
  blend->SetOpacity(0,1);
  blend->SetOpacity(1,.5);

-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!		
Jetzt informieren: http://www.gmx.net/de/go/freephone



More information about the vtkusers mailing list