From 71c9079f5bbeff60cbaea8a171ab5bb2433555ae Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Fri, 22 Dec 2023 17:28:23 +0100 Subject: [PATCH] #3546 bug ColorLayer with images all 0 --- .../bbcreaMaracasVisuColorLayerImageView.cxx | 3 +- .../bbmaracasvisuImageChangeInformation.cxx | 4 --- .../ColorLayerImageView.cxx | 29 ++++++++++--------- .../ColorLayerImageViewManager.cxx | 3 +- .../ColorLayerImageViewPanel.cxx | 1 - .../ThresholdImageView/LayerImageBase.cxx | 7 ++--- 6 files changed, 19 insertions(+), 28 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index 3b9ad12..6fde87a 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -92,7 +92,6 @@ void ColorLayerImageView::Process() std::vector base_color = bbGetInputlstBaseColor(); std::vector grey_level_boundaries = bbGetInputlstGreyLevelBoundaries(); std::vector transparence_level_boundaries = bbGetInputlstTransparenceBoundaries(); - clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() ); clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 1 , bbGetInputWxVtkBaseView1() ); clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 2 , bbGetInputWxVtkBaseView2() ); @@ -104,7 +103,7 @@ void ColorLayerImageView::Process() clivp->GetColorLayerImageViewManager()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() ); clivp->SetFittingMode( bbGetInputFittingMode() ); clivp->SetImage( bbGetInputIn() ); - + bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) ); bbSetOutputLookupTable( clivp->GetColorLayerImageViewManager()->GetLookupTable(0) ); bbSetOutputOutOpacity( clivp->GetOpacity() ); diff --git a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx index 1eb17ae..26314f4 100644 --- a/bbtk/src/bbmaracasvisuImageChangeInformation.cxx +++ b/bbtk/src/bbmaracasvisuImageChangeInformation.cxx @@ -81,14 +81,10 @@ void ImageChangeInformation::Process() mchange->Update(); //important bbSetOutputOut( mchange->GetOutput() ); } else { - printf("EED ImageChangeInformation::Process NULL\n"); bbSetOutputOut( NULL ); - } // if img - } - void ImageChangeInformation::bbUserSetDefaultValues() { mchange = NULL; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx index 869b844..af5bf57 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx @@ -303,7 +303,6 @@ void ColorLayerImageView::SetDefaultBaseColorAndGreyLevelBoundary() //---------------------------------------------------------------------------- void ColorLayerImageView::ConfigLookupTable() // virtual { - // CM 2014 // EED 28/01/2015 // Grey level extrema retrieved from the image grey level extrema. @@ -327,8 +326,8 @@ void ColorLayerImageView::ConfigLookupTable() // virtual { //EED 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; //EED std::cout << "CM The default values for the base colors and the grey level boundaries will be set." << std::endl; - SetDefaultGreyLevelBoundary(); - } // if + SetDefaultGreyLevelBoundary(); + } // if } // _color_type if (_color_type==false) // Gradiant @@ -382,7 +381,6 @@ void ColorLayerImageView::ConfigLookupTable() // virtual thresholdTable->SetNumberOfTableValues( maxColorsThresholdTable+1 ); thresholdTable->SetNanColor(0,0,0,0); - // 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. @@ -435,7 +433,7 @@ void ColorLayerImageView::ConfigLookupTable() // virtual }// for } //if } // End Of if (!_color_type) - + double minRangeForColorBar, maxRangeForColorBar; GetRangeForColorBar( minRangeForColorBar, maxRangeForColorBar ); thresholdTable->SetRange( minRangeForColorBar, maxRangeForColorBar ); @@ -455,24 +453,29 @@ int ColorLayerImageView::GrayLevel_TO_colorTableIndex( double VALUE ) //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 - GetImage()->Update(); + GetImage()->Update(); #else //... #endif //EED 20 oct 2015 // GetImage()->GetScalarRange(_range); - GetImageScalarRange(); - - double minRange = _range[0]; - double maxRange = _range[1]; - return maxColorsThresholdTable * (VALUE-minRange) / (maxRange-minRange); + GetImageScalarRange(); + double minRange = _range[0]; + double maxRange = _range[1]; + + if (maxRange==minRange) + { + return 0; + } else { + 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(); + vtkLookupTable* thresholdTable = GetThresholdTable(); int iTable; double delta = end-start; double dr = (r2-r1)/delta; @@ -483,8 +486,6 @@ void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g { thresholdTable->SetTableValue( iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,t1+dt*iTable); } // for iTable - - } // EOF diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx index 631c11a..cca709a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx @@ -481,7 +481,7 @@ void ColorLayerImageViewManager::SetImageStep2( vtkImageData* img ) } // spc !_spcBase dim!__dimBase this->SetNewSpacingLayer(newSpc); } // img - + if (_active==true) { this->onThreshold(); @@ -491,7 +491,6 @@ void ColorLayerImageViewManager::SetImageStep2( vtkImageData* img ) } // img this->Refresh(); } // _active - } //---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index b5287a8..3d84d07 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -382,7 +382,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _colorLayerImageViewManager->SetImageStep2( img ); // } // img - } //---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index 1b3bec6..3831807 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -459,7 +459,6 @@ void LayerImageBase::onThreshold() directionViewer = wxvtk2dbasevie->GetDirection(); } // ParallelProjection - if (!GetActorPresent()) { if (_thresholdTable==NULL) @@ -497,6 +496,7 @@ void LayerImageBase::onThreshold() _thresholdActor->SetPosition( 0,0, -900-1 ); } } // _thresholdActor + _baseView->GetRenderer()->AddActor( _thresholdActor ); _baseView->GetRenderer()->AddActor2D( _scalarbarActor ); _actorPresent = true; @@ -563,7 +563,7 @@ void LayerImageBase::onThreshold() _thresholdMapper->Update(); _thresholdActor->SetInputData( _thresholdMapper->GetOutput() ); #endif - + _thresholdActor->SetOpacity(_opacity); _scalarbarActor->SetLookupTable( _thresholdTable ); // _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() ); @@ -573,11 +573,8 @@ void LayerImageBase::onThreshold() _scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2); // _scalarbarActor->SetTextPad(4); ?? } // if _image - } - - //---------------------------------------------------------------------------- void LayerImageBase::onThresholdChange() { -- 2.45.1