#include <ThresholdImageView.h>
Public Member Functions | |
ThresholdImageView () | |
~ThresholdImageView () | |
void | SetBaseColor (double r, double g, double b) |
void | SetminMaxValue (int min, int max) |
void | SetZ (int z) |
void | SetImage (vtkImageData *image) |
void | SetwxVtkBaseView (wxVtkBaseView *baseview) |
void | onThreshold () |
void | onThresholdChange () |
void | onThresholdInterpolation (bool interpolate) |
void | onThresholdChangeOpacity (int opacity) |
void | onThresholdRemove () |
wxVtkBaseView * | GetwxVtkBaseView () |
void | Refresh () |
Protected Member Functions | |
virtual int | GetZ () |
vtkLookupTable * | GetThresholdTable () |
vtkImageData * | GetImage () |
Private Member Functions | |
virtual void | ConfigLookupTable () |
Private Attributes | |
double | _baseColorR |
double | _baseColorG |
double | _baseColorB |
double | _minValue |
double | _maxValue |
Definition at line 20 of file ThresholdImageView.h.
ThresholdImageView::ThresholdImageView | ( | ) |
Definition at line 17 of file ThresholdImageView.cxx.
References _baseColorB, _baseColorG, _baseColorR, _maxValue, and _minValue.
00018 { 00019 _minValue = 0; 00020 _maxValue = 1000; 00021 _baseColorR = 1; 00022 _baseColorG = 0; 00023 _baseColorB = 0; 00024 }
ThresholdImageView::~ThresholdImageView | ( | ) |
Definition at line 27 of file ThresholdImageView.cxx.
void ThresholdImageView::ConfigLookupTable | ( | ) | [private, virtual] |
Implements LayerImageBase.
Definition at line 43 of file ThresholdImageView.cxx.
References _baseColorB, _baseColorG, _baseColorR, _maxValue, _minValue, LayerImageBase::GetImage(), and LayerImageBase::GetThresholdTable().
00044 { 00045 double range[2]; 00046 00047 GetImage()->GetScalarRange(range); 00048 if (range[1]==0) 00049 { 00050 range[1]=255; 00051 } 00052 00053 int minTot = floor (range[0]); 00054 int maxTot = ceil (range[1]); 00055 00056 int minVal = floor (_minValue); 00057 int maxVal = floor (_maxValue); 00058 00059 vtkLookupTable* thresholdTable = GetThresholdTable(); 00060 thresholdTable->SetNumberOfTableValues(maxTot+1); 00061 thresholdTable->SetTableRange(range); 00062 thresholdTable->SetAlphaRange(0, 1); 00063 thresholdTable->SetValueRange(0, 1); 00064 thresholdTable->SetSaturationRange(0, 0); 00065 thresholdTable->SetRampToLinear( ); 00066 00067 //Assign a fake color for the upper image, and set the white as transparent 00068 int i; 00069 for(i = minTot; i <= maxTot; i++) 00070 { 00071 if( i >= minVal && i <= maxVal ) 00072 { 00073 thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1); 00074 } 00075 else if( i >= minTot && i < minVal ) 00076 { 00077 thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent 00078 } 00079 else if( i > maxVal && i < maxTot ) 00080 { 00081 thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent 00082 } 00083 else 00084 { 00085 thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent 00086 } 00087 } // for 00088 thresholdTable->Build( ); 00089 00090 }
vtkImageData * LayerImageBase::GetImage | ( | ) | [protected, inherited] |
Definition at line 40 of file LayerImageBase.cxx.
References LayerImageBase::_image.
Referenced by ConfigLookupTable(), ColorLayerImageView::ConfigLookupTable(), and LayerImageBase::onThreshold().
00041 { 00042 return _image; 00043 }
vtkLookupTable * LayerImageBase::GetThresholdTable | ( | ) | [protected, inherited] |
Definition at line 82 of file LayerImageBase.cxx.
References LayerImageBase::_thresholdTable.
Referenced by ConfigLookupTable(), and ColorLayerImageView::ConfigLookupTable().
00083 { 00084 return _thresholdTable; 00085 }
wxVtkBaseView * LayerImageBase::GetwxVtkBaseView | ( | ) | [inherited] |
Definition at line 66 of file LayerImageBase.cxx.
References LayerImageBase::_baseView.
Referenced by ThresholdImageViewPanel::onChangeOpacity(), ThresholdImageViewPanel::onThresholdChange(), ThresholdImageViewPanel::onThresholdInterpolation(), and ThresholdImageViewPanel::onThresholdShow().
00067 { 00068 return _baseView; 00069 }
int LayerImageBase::GetZ | ( | ) | [protected, virtual, inherited] |
Reimplemented in ColorLayerImageView.
Definition at line 34 of file LayerImageBase.cxx.
References LayerImageBase::_Z.
Referenced by LayerImageBase::onThreshold().
00035 { 00036 return _Z; 00037 }
void LayerImageBase::onThreshold | ( | ) | [inherited] |
Definition at line 107 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, LayerImageBase::_baseView, LayerImageBase::_image, LayerImageBase::_imageReslicer, LayerImageBase::_thresholdActor, LayerImageBase::_thresholdMapper, LayerImageBase::_thresholdTable, LayerImageBase::CleanZ(), LayerImageBase::ConfigLookupTable(), LayerImageBase::GetActorPresent(), LayerImageBase::GetImage(), wxVtkBaseView::GetRenderer(), and LayerImageBase::GetZ().
Referenced by ColorLayerImageViewPanel::onReadImage(), ColorLayerImageViewPanel::onSliceFixDinamic(), ColorLayerImageViewPanel::onSliceImage(), LayerImageBase::onThresholdChange(), ThresholdImageViewPanel::onThresholdShow(), and ColorLayerImageViewPanel::onThresholdShow().
00108 { 00109 00110 if ((_image!=NULL) && (_baseView!=NULL)) 00111 { 00112 int z=CleanZ( GetZ() ); 00113 00114 if (!GetActorPresent()) 00115 { 00116 if (_thresholdTable==NULL) 00117 { 00118 //Lookup Table 00119 _thresholdTable = vtkLookupTable::New(); 00120 } // _thresholdTable 00121 00122 if (_thresholdMapper==NULL) 00123 { 00124 _thresholdMapper = vtkImageMapToColors::New( ); 00125 } 00126 00127 if (_thresholdActor==NULL) 00128 { 00129 _thresholdActor = vtkImageActor::New( ); 00130 _thresholdActor->SetOpacity( 0.6 ); 00131 _thresholdActor->InterpolateOn( ); 00132 _thresholdActor->SetPosition( 0,0, 900-1 ); 00133 } // _thresholdActor 00134 _baseView->GetRenderer()->AddActor( _thresholdActor ); 00135 _actorPresent = true; 00136 } // !GetActorPresent() 00137 00138 ConfigLookupTable(); // virtual method 00139 _imageReslicer->SetInput( GetImage() ); 00140 _imageReslicer->SetInformationInput( GetImage() ); 00141 _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); 00142 _imageReslicer->SetOutputDimensionality(2); 00143 _imageReslicer->SetInterpolationModeToLinear(); 00144 _imageReslicer->SetResliceAxesOrigin(0,0,z); 00145 00146 vtkImageData *img = _imageReslicer->GetOutput(); 00147 img->Update(); 00148 img->UpdateInformation(); 00149 00150 _thresholdMapper->SetInput( img ); 00151 _thresholdMapper->SetLookupTable( _thresholdTable ); 00152 _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); 00153 } // _image 00154 }
void LayerImageBase::onThresholdChange | ( | ) | [inherited] |
Definition at line 159 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, and LayerImageBase::onThreshold().
Referenced by ThresholdImageViewPanel::onThresholdChange(), and ColorLayerImageViewPanel::onThresholdChange().
00160 { 00161 if (_actorPresent) 00162 { 00163 onThreshold(); 00164 } 00165 }
void LayerImageBase::onThresholdChangeOpacity | ( | int | opacity | ) | [inherited] |
Definition at line 184 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, and LayerImageBase::_thresholdActor.
Referenced by ThresholdImageViewPanel::onChangeOpacity(), and ColorLayerImageViewPanel::onChangeOpacity().
00185 { 00186 if (_actorPresent) 00187 { 00188 _thresholdActor->SetOpacity(opacity*0.1); 00189 } 00190 }
void LayerImageBase::onThresholdInterpolation | ( | bool | interpolate | ) | [inherited] |
Definition at line 168 of file LayerImageBase.cxx.
References LayerImageBase::_thresholdActor.
Referenced by ThresholdImageViewPanel::onThresholdInterpolation(), and ColorLayerImageViewPanel::onThresholdInterpolation().
00169 { 00170 if (_thresholdActor!=NULL) 00171 { 00172 if (interpolate) 00173 { 00174 _thresholdActor->InterpolateOn( ); 00175 } 00176 else 00177 { 00178 _thresholdActor->InterpolateOff( ); 00179 } 00180 } 00181 }
void LayerImageBase::onThresholdRemove | ( | ) | [inherited] |
Definition at line 193 of file LayerImageBase.cxx.
References LayerImageBase::_actorPresent, LayerImageBase::_baseView, LayerImageBase::_thresholdActor, and wxVtkBaseView::GetRenderer().
Referenced by ThresholdImageViewPanel::onThresholdShow(), ColorLayerImageViewPanel::onThresholdShow(), ThresholdImageViewPanel::onThresholdStop(), and ColorLayerImageViewPanel::onThresholdStop().
00194 { 00195 if (_actorPresent) 00196 { 00197 wxVtkBaseView * baseView = _baseView; 00198 baseView->GetRenderer()->RemoveActor( _thresholdActor ); 00199 _actorPresent = false; 00200 } 00201 }
void LayerImageBase::Refresh | ( | ) | [inherited] |
Definition at line 72 of file LayerImageBase.cxx.
References LayerImageBase::_baseView, and wxVtkBaseView::Refresh().
Referenced by ColorLayerImageViewPanel::onChangeOpacity(), ColorLayerImageViewPanel::onReadImage(), ColorLayerImageViewPanel::onSliceFixDinamic(), ColorLayerImageViewPanel::onSliceImage(), ColorLayerImageViewPanel::onThresholdChange(), ColorLayerImageViewPanel::onThresholdInterpolation(), and ColorLayerImageViewPanel::onThresholdShow().
void ThresholdImageView::SetBaseColor | ( | double | r, | |
double | g, | |||
double | b | |||
) |
Definition at line 94 of file ThresholdImageView.cxx.
References _baseColorB, _baseColorG, and _baseColorR.
00095 { 00096 _baseColorR = r; 00097 _baseColorG = g; 00098 _baseColorB = b; 00099 }
void LayerImageBase::SetImage | ( | vtkImageData * | image | ) | [inherited] |
Definition at line 54 of file LayerImageBase.cxx.
References LayerImageBase::_image.
Referenced by ColorLayerImageViewPanel::onReadImage().
00055 { 00056 _image = image; 00057 }
void ThresholdImageView::SetminMaxValue | ( | int | min, | |
int | max | |||
) |
Definition at line 35 of file ThresholdImageView.cxx.
References _maxValue, and _minValue.
Referenced by ThresholdImageViewPanel::onThresholdChange().
void LayerImageBase::SetwxVtkBaseView | ( | wxVtkBaseView * | baseview | ) | [inherited] |
Definition at line 60 of file LayerImageBase.cxx.
References LayerImageBase::_baseView.
00061 { 00062 _baseView = baseview; 00063 }
void LayerImageBase::SetZ | ( | int | z | ) | [inherited] |
Definition at line 28 of file LayerImageBase.cxx.
References LayerImageBase::_Z.
00029 { 00030 _Z = z; 00031 }
double ThresholdImageView::_baseColorB [private] |
Definition at line 31 of file ThresholdImageView.h.
Referenced by ConfigLookupTable(), SetBaseColor(), and ThresholdImageView().
double ThresholdImageView::_baseColorG [private] |
Definition at line 30 of file ThresholdImageView.h.
Referenced by ConfigLookupTable(), SetBaseColor(), and ThresholdImageView().
double ThresholdImageView::_baseColorR [private] |
Definition at line 29 of file ThresholdImageView.h.
Referenced by ConfigLookupTable(), SetBaseColor(), and ThresholdImageView().
double ThresholdImageView::_maxValue [private] |
Definition at line 33 of file ThresholdImageView.h.
Referenced by ConfigLookupTable(), SetminMaxValue(), and ThresholdImageView().
double ThresholdImageView::_minValue [private] |
Definition at line 32 of file ThresholdImageView.h.
Referenced by ConfigLookupTable(), SetminMaxValue(), and ThresholdImageView().