mImage = 0;
mSlicer = 0;
mColorLUT = vtkLookupTable::New();
+ mForegroundValue = 1;
+ mBackgroundValue = 0;
+ m_modeBG = true;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::Initialize()
+void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
{
if (!mSlicer) {
std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl;
// how many intensity ?
vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New();
mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
- mColorLUT->SetRange(0,1);
- mColorLUT->SetNumberOfTableValues(2);
- mColorLUT->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0); // BG
- mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
+
+ double range[2];
+ mImage->GetVTKImages()[0]->GetScalarRange(range);
+ int n = range[1]-range[0]+1;
+ mColorLUT->SetRange(range[0],range[1]);
+ mColorLUT->SetNumberOfTableValues(n);
+
+ // Mode BG -> all is color except BG
+ if (m_modeBG) {
+ for(int i=0; i<n; i++) {
+ mColorLUT->SetTableValue(i, mColor[0], mColor[1], mColor[2], mAlpha);
+ }
+ mColorLUT->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0);
+ }
+ else {
+ // Mode FG -> all is BG, except FG which is color
+ for(int i=0; i<n; i++) {
+ mColorLUT->SetTableValue(i, 0, 0, 0, 0.0);
+ }
+ mColorLUT->SetTableValue(mForegroundValue, mColor[0], mColor[1], mColor[2], mAlpha);
+ }
+
mOverlayMapper->SetLookupTable(mColorLUT);
vtkImageActor * mOverlayActor = vtkImageActor::New();
mOverlayActor->SetInput(mOverlayMapper->GetOutput());
mOverlayActor->SetPickable(0);
- mOverlayActor->SetVisibility(true);
+ mOverlayActor->SetVisibility(IsVisible);
//mOverlayActor->SetOpacity(1.0);
mMapperList.push_back(mOverlayMapper);
//------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg)
+void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG)
{
mImage = image;
- mBackgroundValue = bg;
+ if (modeBG) {
+ mBackgroundValue = bg;
+ m_modeBG = true;
+ }
+ else {
+ mForegroundValue = bg;
+ m_modeBG = false;
+ }
}
//------------------------------------------------------------------------------
int * inExtent,
int * outExtent)
{
- // std::cout << "InExtent = " << inExtent[0] << " " << inExtent[1] << " " << inExtent[2] << " "
- // << inExtent[3] << " " << inExtent[4] << " " << inExtent[5] << std::endl;
- // DD(orientation);
switch (orientation) {
case vtkImageViewer2::SLICE_ORIENTATION_XY:
for(int i=0; i<4; i++) outExtent[i] = inExtent[i];
outExtent[0] = outExtent[1] = slice;
break;
}
- // std::cout << "OutExtent = " << outExtent[0] << " " << outExtent[1] << " " << outExtent[2] << " "
- // << outExtent[3] << " " << outExtent[4] << " " << outExtent[5] << std::endl;
}
//------------------------------------------------------------------------------