void ColorLayerImageView::SetBaseColors(std::vector<double> & base_color)
{
// The base color vector must be of a size multiple of 3, not null.
- if (base_color.size() != 0 && base_color.size() % 3 == 0)
- _base_color = base_color;
- // Otherwise, an exception should be thrown.
- else if (base_color.size() != 0)
- std::cout << "CM ColorLayerImageView::SetBaseColors : ERROR!!! The base color vector has an inconsistent size. It must be of a size multiple of 3, different from 0, but its size is: "<< base_color.size() << ". Therefore, the default values will be used as base colors." << std::endl;
+//EED if ((base_color.size() != 0) && (base_color.size() % 3 == 0))
+ if ( base_color.size() % 3 == 0)
+ {
+ _base_color = base_color;
+ } else if (base_color.size() != 0) // Otherwise, an exception should be thrown.
+ {
+ std::cout << "CM ColorLayerImageView::SetBaseColors : ERROR!!! The base color vector has an inconsistent size. It must be of a size multiple of 3, different from 0, but its size is: "<< base_color.size() << ". Therefore, the default values will be used as base colors." << std::endl;
+ }
}
int i;
double delta;
- // Grey level extrema are set by default to the image grey level extrema.
- double minTot = _range[0];
- double maxTot = _range[1];
+ // Grey level extrema are set by default to the image grey level extrema.
+ double minTot = _range[0];
+ double maxTot = _range[1];
if (_color_type)
{
void ColorLayerImageView::ConfigLookupTable() // virtual
{
// CM 2014
- // EED 28/01/2015
-
+ // EED 28/01/2015
// Grey level extrema retrieved from the image grey level extrema.
-
- GetImage()->GetScalarRange(_range);
+//EED 20 oct 2015
+// GetImage()->GetScalarRange(_range);
+ GetImageScalarRange();
double minRange = _range[0];
double maxRange = _range[1];
// ------------------ Defining the Threshold Table
vtkLookupTable* thresholdTable = GetThresholdTable();
+
double thresholdTable_range[2];
double r1,r2,g1,g2,b1,b2,t1,t2;
int start,end;
thresholdTable_range[1]= std::max( GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) , ceil(maxRange) );
thresholdTable_range[0]= std::min( GetGreyLevelBoundaries(0), floor(minRange) );
+ thresholdTable_range[1]= GetGreyLevelBoundaries( _grey_level_boundary.size()-1 );
+ thresholdTable_range[0]= GetGreyLevelBoundaries(0);
+
thresholdTable->SetTableRange(thresholdTable_range);
thresholdTable->SetAlphaRange( 0,1 );
thresholdTable->SetValueRange( 0,1 );
maxColorsThresholdTable = 1000;
thresholdTable->SetNumberOfTableValues( maxColorsThresholdTable );
+ thresholdTable->SetNanColor(0,0,0,0);
// Defines the lookup table.
{
if ( minRange<GetGreyLevelBoundaries(0) )
{
- start = 0;
+ start = 0;
end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(0) );
FillColorTable(start,end, 0,0,0, 0,0,0, 0,0);
}
if ( maxRange>GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) )
{
- start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) );
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) );
end = GrayLevel_TO_colorTableIndex( maxRange );
FillColorTable(start,end, 0,0,0, 0,0,0, 0,0);
}
r1 = GetBaseColors(iColor*3+0);
g1 = GetBaseColors(iColor*3+1);
b1 = GetBaseColors(iColor*3+2);
- start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );
- t1 = _transparence_level_boundary[iColor];
+ t1 = _transparence_level_boundary[iColor];
// t2 = _transparence_level_boundary[iColor+1];
FillColorTable(start,end, r1,g1,b1,r1,g1,b1,t1,t1);
} // for i
r2 = GetBaseColors( (iColor+1)*3+0);
g2 = GetBaseColors( (iColor+1)*3+1);
b2 = GetBaseColors( (iColor+1)*3+2);
- start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );
- t1 = _transparence_level_boundary[iColor];
+ t1 = _transparence_level_boundary[iColor];
t2 = _transparence_level_boundary[iColor+1];
FillColorTable( start,end, r1,g1,b1, r2,g2,b2, t1,t2 );
}// for
int ColorLayerImageView::GrayLevel_TO_colorTableIndex( double VALUE )
{
GetImage()->Update();
- GetImage()->GetScalarRange(_range);
+
+//EED 20 oct 2015
+// GetImage()->GetScalarRange(_range);
+ GetImageScalarRange();
+
double minRange = _range[0];
double maxRange = _range[1];
return maxColorsThresholdTable * (VALUE-minRange) / (maxRange-minRange);
void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2, double t1, double t2)
{
vtkLookupTable* thresholdTable = GetThresholdTable();
- int iTable;
- double delta = end-start;
- double dr = (r2-r1)/delta;
- double dg = (g2-g1)/delta;
- double db = (b2-b1)/delta;
- double dt = (t2-t1)/delta;
+ int iTable;
+ double delta = end-start;
+ double dr = (r2-r1)/delta;
+ double dg = (g2-g1)/delta;
+ double db = (b2-b1)/delta;
+ double dt = (t2-t1)/delta;
for (iTable=0; iTable<=delta; iTable++)
{
thresholdTable->SetTableValue( iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,t1+dt*iTable);
virtual int GetX();
virtual int GetY();
virtual int GetZ();
- void SetwxVtkBaseView(int id, wxVtkBaseView *baseview);
- void SetBaseColors(std::vector<double> & base_color);
- double GetBaseColors(unsigned int index);
- void SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary);
- void SetBaseTransparence(std::vector<double> & base_transparence);
- void SetRangeForColorBar(std::vector<double> & range);
- double GetGreyLevelBoundaries(unsigned int index);
- void SetPlainOrGradientColor(bool color_type);
- int GetBaseColorNb();
- void Refresh();
- void onThreshold();
- void onThresholdRemove();
- void onThresholdChange();
- void onThresholdInterpolation(bool interpolation);
- void SetSliceFixDynamic( bool fixdin );
- void onThresholdChangeOpacity( int opacity);
- void SetImage( vtkImageData* img );
+ void SetwxVtkBaseView(int id, wxVtkBaseView *baseview);
+ void SetBaseColors(std::vector<double> & base_color);
+ double GetBaseColors(unsigned int index);
+ void SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary);
+ void SetBaseTransparence(std::vector<double> & base_transparence);
+ void SetRangeForColorBar(std::vector<double> & range);
+ double GetGreyLevelBoundaries(unsigned int index);
+ void SetPlainOrGradientColor(bool color_type);
+ int GetBaseColorNb();
+ void Refresh();
+ void onThreshold();
+ void onThresholdRemove();
+ void onThresholdChange();
+ void onThresholdInterpolation( bool interpolation );
+ void SetSliceFixDynamic( bool fixdin );
+ void onThresholdChangeOpacity( int opacity );
+ void SetImage( vtkImageData* img );
private:
std::vector< ColorLayerImageView* > _colorLayerImageViewLst;