[vtkusers] Change to vtkLookupTable Slows Application

Tim Soper tim_d_soper at yahoo.com
Thu Oct 16 18:31:29 EDT 2008


Hi,

I have an application where I visualize the same image data in several windows. I vizualize both grayscale image data, and a binary mask that overlays the image data at regions that are segmented. To display the mask overlay, I use a vtkLookupTable  and define each table value manually to get distinct color values for each mask value (i.e. 0 = transparent, 1 = green, 2 = red, etc)

Here's how I build the LUT

    vtkLookupTable* lut = vtkLookupTable::New();
    lut->SetNumberOfTableValues(4);
    lut->SetRange(0.0,3.0);
    lut->SetTableValue( 0, 0.0, 0.0, 0.0, 0.0 );              //label 0 is transparent
    lut->SetTableValue( 1, 0.0, 1.0, 0.0, this->MaskOpacity );//label 1 is green
    lut->SetTableValue( 2, 1.0, 0.0, 0.0, this->MaskOpacity );//label 2 is red
    lut->SetTableValue( 3, 0.0, 1.0, 1.0, this->MaskOpacity );//label 3 is cyan
    lut->Build();
    this->ScalarMaskToColor->SetLookupTable( lut );

Simultaneously, I use mouse interaction to control window and leveling of the grayscale image, This is typically very fast, and the changes to the image do not lag. Once I try to change the transparency of the values in my lookup table, however, the rest of the application slows down a bit. I do this so that I can adjust the opacity of my mask to see the underlying grayscale image data, but I get the same result for any change (not just opacity)

I've pinpointed the code which causes my application to slow to the following function:
     :
     :
/////////////////////////////////////////////////////////
SetMaskOpacity( double opacity )
{

    vtkLookupTable* lut = reinterpret_cast<vtkLookupTable*>
        ( this->ScalarMaskToColor->GetLookupTable() );
    
    double rgba[4];

    for(int i = 1; i < lut->GetNumberOfTableValues(); i++)    //start from label 1
    {                                                                               //label 0 is always
        lut->GetTableValue(i,rgba);                                      //transparent
        rgba[3] = opacity; 
        lut->SetTableValue(i,rgba);
    }
    lut->Build();
    lut->Modified();
    this->Render();
}
//////////////////////////////////////////////
     :
     :

I don't understand why changing this value causes the rendering to slow incredibly. No matter what, the slow-down is caused by any manner of changing a table value. I also don't beleive it has anything to do with the value I'm inputting. If I set the table value to be the exact same as it was, I still have a problem.
I don't get it. Any ideas? Thanks for any advice you might give



 Tim Soper


Research Assistant
University of Washington
Department of Bioengineering 
Box 352142


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the vtkusers mailing list