_z2 = z2;
}
-
-
//----------------------------------------------------------------------------
int ColorLayerImageView::GetX() // virtual
{
SetDefaultBaseColorAndGreyLevelBoundary();
}
else { // If at least one color has been set, set the grey level boundaries to build an equipartition of the image grey levels, keeping the base colors defined.
- if (GetBaseColorNb() != (_grey_level_boundary.size() - 1) )
+ if (GetBaseColorNb() != ((int)_grey_level_boundary.size() - 1) )
{
std::cout << "CM ColorLayerImageView::ConfigLookupTable : ERROR!!! Inconsistency between the sizes of vectors _base_color and _grey_level_boundary. _base_color.size()/3 (=" <<_base_color.size()/3 << ") should be equal to _grey_level_boundary.size() - 1 (=" << _grey_level_boundary.size() - 1 << ")." << std::endl;
std::cout << "CM The default values for the base colors and the grey level boundaries will be set." << std::endl;
thresholdTable->SetSaturationRange(0, 0);
thresholdTable->SetRampToLinear( );
- thresholdTable->SetNumberOfTableValues(1000);
+ maxColorsThresholdTable = 1000;
+ thresholdTable->SetNumberOfTableValues( maxColorsThresholdTable );
// Defines the lookup table.
// Sets the plain color for each grey level interval.
if (_color_type)
{
-// thresholdTable->SetNumberOfTableValues(thresholdTable_range[1] - thresholdTable_range[0] + 1);
if ( minRange<GetGreyLevelBoundaries(0) )
{
start = 0;
- end = 1000*(GetGreyLevelBoundaries(0)-minRange) / (maxRange-minRange);
+ end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(0) );
FillColorTable(start,end, 0,0,0, 0,0,0);
}
if ( maxRange>GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) )
{
- start = 1000*(GetGreyLevelBoundaries( _grey_level_boundary.size()-1 )-minRange) / (maxRange-minRange);;
- end = 1000*(maxRange-minRange) / (maxRange-minRange);
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) );
+ end = GrayLevel_TO_colorTableIndex( maxRange );
FillColorTable(start,end, 0,0,0, 0,0,0);
}
- int delta;
for (int iColor = 0; iColor < GetBaseColorNb(); iColor++)
{
-
- start = 1000*(GetGreyLevelBoundaries(iColor)-minRange) / (maxRange-minRange);
- end = 1000*(GetGreyLevelBoundaries(iColor+1)-minRange) / (maxRange-minRange);
-
r1 = GetBaseColors(iColor*3+0);
g1 = GetBaseColors(iColor*3+1);
b1 = GetBaseColors(iColor*3+2);
-
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
+ end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );
FillColorTable(start,end, r1,g1,b1,r1,g1,b1);
-
-/*
- 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);
- } // for ii
-*/
-
} // for i
} // End Of if (_color_type)
else
{
//EED 28/01/2015
- thresholdTable->SetNumberOfTableValues(1000);
if (GetBaseColorNb() > 1)
{
for (int iColor = 0; iColor < GetBaseColorNb(); iColor++)
r2 = GetBaseColors(iColor*3+0);
g2 = GetBaseColors(iColor*3+1);
b2 = GetBaseColors(iColor*3+2);
- start = 1000*(GetGreyLevelBoundaries(iColor)-minRange) / (maxRange-minRange);
- end = 1000*(GetGreyLevelBoundaries(iColor+1)-minRange) / (maxRange-minRange);
- FillColorTable(start,end, r1,g1,b1,r2,g2,b2);
+ start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );
+ end = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );
+ FillColorTable( start,end, r1,g1,b1, r2,g2,b2 );
}// for
} //if
} // End Of if (!_color_type)
+ thresholdTable->SetRange( minRange, maxRange );
+ thresholdTable->SetValueRange( 0.0, 1.0 );
+
thresholdTable->Build( );
//EO CM EED
}
+//----------------------------------------------------------------------------
+int ColorLayerImageView::GrayLevel_TO_colorTableIndex( double VALUE )
+{
+ GetImage()->GetScalarRange(_range);
+ 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)
{
vtkLookupTable* thresholdTable = GetThresholdTable();
- int iTable;
- double delta = end-start;
- double dr = (r2-r1)/delta;
- double dg = (g2-g1)/delta;
- double db = (b2-b1)/delta;
+ int iTable;
+ double delta = end-start;
+ double dr = (r2-r1)/delta;
+ double dg = (g2-g1)/delta;
+ double db = (b2-b1)/delta;
for (iTable=0; iTable<=delta; iTable++)
{
thresholdTable->SetTableValue( iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,1);
} // for iTable
+
+ if (start==0) thresholdTable->SetTableValue( start , r1, g1, b1,0); // The first color in the table is transparent
+
}
// EOF
wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 3 , lstOptOperation, 3, wxRA_SPECIFY_COLS);
dialSizer->Add( new wxStaticText(dial,-1,message) , 0, wxGROW );
- // dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?")) , 0, wxGROW );
dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
dialSizer->Add(radioOpts,0,wxGROW);
dialSizer->Add( new wxStaticText(dial,-1,_T(" ")) , 0, wxGROW );
ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
{
- printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel start \n");
_spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
_dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
-//EED01 _colorLayerImageView = new ColorLayerImageView();
_colorLayerImageViewManager = new ColorLayerImageViewManager();
_btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") );
else
typeOfTransformation = _fitting_mode;
//EO CM
-
- printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
-
if (typeOfTransformation==1) // make dimensions equals
{
printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
img->SetSpacing(spc);
} // spc !_spcBase dim!__dimBase
-//EED01 if (_colorLayerImageView!=NULL)
-//EED01 {
-//EED01 _colorLayerImageView->onThreshold();
if (_active==true)
{
_colorLayerImageViewManager->onThreshold();
RefreshView();
}
-//EED01 }
}
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
{
-//EED01 if (_colorLayerImageView!=NULL)
-//EED01 {
if (_thresholdGo)
{
-//EED01 _colorLayerImageView->onThresholdChange();
_colorLayerImageViewManager->onThresholdChange();
RefreshView();
//std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
} // _thresholdGo
-//EED01 }//_colorLayerImageView
}
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
{
-//EED01 if (_colorLayerImageView!=NULL)
-//EED01 {
_thresholdGo = _cb_ShowHide->GetValue();
if (_thresholdGo)
{
-//EED01 _colorLayerImageView->onThreshold();
_colorLayerImageViewManager->onThreshold();
}else{
-//EED01 _colorLayerImageView->onThresholdRemove( );
_colorLayerImageViewManager->onThresholdRemove( );
}
RefreshView();
-//EED01 }//_colorLayerImageView
}
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onThresholdStop()
{
-//EED01 if (_colorLayerImageView!=NULL)
-//EED01 {
if (_thresholdGo)
{
-//EED01 _colorLayerImageView->onThresholdRemove( );
_colorLayerImageViewManager->onThresholdRemove( );
_thresholdGo=false;
}
-//EED01 }//_colorLayerImageView
}
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
{
-//EED01 if (_colorLayerImageView!=NULL)
-//EED01 {
-//EED01 _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
_colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
RefreshView();
-//EED01 }//_colorLayerImageView
}
//----------------------------------------------------------------------------