/** * \file * \brief Class bbtk::ThresholdImageView . */ #include "ColorLayerImageView.h" #include #include #include //========================================================================= //========================================================================= //========================================================================= //========================================================================= ColorLayerImageView::ColorLayerImageView( ) { _z2 = 0; _fix_dinamic = true; } //========================================================================= ColorLayerImageView::~ColorLayerImageView() { } //========================================================================= //---------------------------------------------------------------------------- void ColorLayerImageView::SetSliceFixDinamic(bool fix_dinamic) { _fix_dinamic = fix_dinamic; } //---------------------------------------------------------------------------- void ColorLayerImageView::SetZ2(int z2) { _z2 = z2; } //---------------------------------------------------------------------------- int ColorLayerImageView::GetZ() // virtual { int result=0; if (_fix_dinamic==false) { result = _z2; } else { result = LayerImageBase::GetZ(); } return result; } //---------------------------------------------------------------------------- void ColorLayerImageView::ConfigLookupTable() // virtual { double range[2]; GetImage()->GetScalarRange(range); if (range[1]==0) { range[1]=255; } int minTot = floor (range[0]); int maxTot = ceil (range[1]); vtkLookupTable* thresholdTable = GetThresholdTable(); thresholdTable->SetNumberOfTableValues(maxTot+1); thresholdTable->SetTableRange(range); thresholdTable->SetAlphaRange(0, 1); thresholdTable->SetValueRange(0, 1); thresholdTable->SetSaturationRange(0, 0); thresholdTable->SetRampToLinear( ); //Assign a fake color for the upper image, and set the white as transparent int i,ii; double iBlue=0 , iYellow=0 , iRed=0; double delta=(maxTot-minTot)/3.0; double delta0=delta*0; double delta1=delta*1; double delta2=delta*2; // double delta3=delta*3; double delta3=maxTot; for(i = minTot; i <= maxTot; i++) { ii=i-minTot; if ((ii>=delta0) && (ii<=delta1)) // iBlue { thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1); if (ii==0) { thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 0); } else { thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1); } iBlue++; } if ((ii>=delta1) && (ii<=delta2)) // iYellow { thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1); iYellow++; } if ((ii>=delta2) && (ii<=delta3)) // iRed { thresholdTable->SetTableValue( i , 1, (delta-iRed)/delta , 0 , 1); iRed++; } } // for thresholdTable->Build( ); } // EOF