+ // CM Number of table values consistent with the effective number of values (see loop below).
+ double thresholdTable_range[2];
+ thresholdTable_range[1]= std::max( GetGreyLevelBoundaries( GetBaseColorNb() ), ceil(_range[1]) );
+ thresholdTable_range[0]= std::min( GetGreyLevelBoundaries(0), floor(_range[0]) );
+ thresholdTable->SetNumberOfTableValues(thresholdTable_range[1] - thresholdTable_range[0] + 1);
+ thresholdTable->SetTableRange(thresholdTable_range);
+ thresholdTable->SetAlphaRange(0, 1);
+ thresholdTable->SetValueRange(0, 1);
+ thresholdTable->SetSaturationRange(0, 0);
+ thresholdTable->SetRampToLinear( );
+
+ // Defines the lookup table.
+ // If the image has a degradation in one (or both) extremum (lower or higher),
+ // sets the corresponding grey levels as transparent white in the lookup table.
+ for (int i = floor(_range[0]); i <= GetGreyLevelBoundaries(0); i++)
+ {
+ thresholdTable -> SetTableValue( i, 0, 0, 0, 0);
+ }
+ for (int i = GetGreyLevelBoundaries( GetBaseColorNb() ) + 1 ; i <= ceil(_range[1]); i++)
+ {
+ thresholdTable -> SetTableValue( i, 0, 0, 0, 0);
+ }
+
+ int delta;
+
+ // _color_type true, i.e. plain colors.
+ // Sets the plain color for each grey level interval.
+ if (_color_type)
+ {
+ for (int i = 0; i < GetBaseColorNb(); i++)
+ {
+ delta = GetGreyLevelBoundaries(i+1) - GetGreyLevelBoundaries(i);
+ for (int ii = 1; ii <= delta; ii++)
+ {
+ thresholdTable->SetTableValue(GetGreyLevelBoundaries(i) + ii,
+ GetBaseColors(i*3),
+ GetBaseColors(i*3 + 1),
+ GetBaseColors(i*3 + 2),
+ 1);
+ }
+ }
+ } // End Of if (_color_type)