From 1b20471b20f7f0ad03c2c13ebb5f3ace2a523ea8 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@c-s.fr> Date: Mon, 19 Feb 2007 12:22:10 +0000 Subject: [PATCH] Viewer, version quasi-finale. --- Code/Visu/otbImageViewer.h | 12 +++++-- Code/Visu/otbImageViewer.txx | 49 ++++++++++++++++++-------- Code/Visu/otbImageViewerFullWidget.h | 5 +++ Code/Visu/otbImageViewerScrollWidget.h | 5 +++ Code/Visu/otbImageWidgetBase.txx | 6 ++-- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/Code/Visu/otbImageViewer.h b/Code/Visu/otbImageViewer.h index e7a2cadb17..bec51ab121 100644 --- a/Code/Visu/otbImageViewer.h +++ b/Code/Visu/otbImageViewer.h @@ -92,12 +92,18 @@ class ITK_EXPORT ImageViewer itkGetMacro(BlueChannelIndex,unsigned int); itkSetMacro(Label,char *); itkGetMacro(Label,const char *); + itkSetMacro(QuicklookRatioCoef,double); + itkGetMacro(QuicklookRatioCoef,double); + itkSetMacro(NormalizationFactor,double); + itkGetMacro(NormalizationFactor,double); /** Set the input image */ virtual void SetImage(itk::ImageBase<2> * img); /** Show the viewer (Update) */ virtual void Show(void); + /** Hide all Image View Windows */ + virtual void Hide(void); virtual void ComputeNormalizationFactors(void); @@ -119,8 +125,7 @@ protected: ImageViewer(); ~ImageViewer(); - /** Hide all Image View Windows */ - virtual void Hide(void); + private: /// zoom widget component @@ -154,6 +159,9 @@ protected: unsigned int m_RedChannelIndex; unsigned int m_GreenChannelIndex; unsigned int m_BlueChannelIndex; + + double m_QuicklookRatioCoef; + double m_NormalizationFactor; const char * m_Label; }; diff --git a/Code/Visu/otbImageViewer.txx b/Code/Visu/otbImageViewer.txx index 025fa8cbb2..8dac2a46f7 100644 --- a/Code/Visu/otbImageViewer.txx +++ b/Code/Visu/otbImageViewer.txx @@ -55,6 +55,8 @@ namespace otb m_PixLocWindow=NULL; m_PixLocOutput=NULL; m_Label="OTB Image viewer"; + m_NormalizationFactor = 3.; + m_QuicklookRatioCoef = 2; } /// Destructor template <class TPixel> @@ -127,24 +129,24 @@ namespace otb typename CovarianceCalculatorType::OutputType cov = *(calc->GetOutput()); for(unsigned int i = 0; i<nbComponents;++i) { - m_MinComponentValue[i] = static_cast<InputPixelType>((calc->GetMean())->GetElement(i)-2.8*vcl_sqrt(cov(i,i))); - m_MaxComponentValue[i] = static_cast<InputPixelType>((calc->GetMean())->GetElement(i)+2.8*vcl_sqrt(cov(i,i))); - if(m_MinComponentValue[i]<absolutMin[i]) + m_MinComponentValue[i] = static_cast<InputPixelType>((calc->GetMean())->GetElement(i)-m_NormalizationFactor*vcl_sqrt(cov(i,i))); + m_MaxComponentValue[i] = static_cast<InputPixelType>((calc->GetMean())->GetElement(i)+m_NormalizationFactor*vcl_sqrt(cov(i,i))); + if(m_MinComponentValue[i]<absolutMin[i]) m_MinComponentValue[i]=absolutMin[i]; - if(m_MaxComponentValue[i]>absolutMax[i]) + if(m_MaxComponentValue[i]>absolutMax[i]) m_MaxComponentValue[i]=absolutMax[i]; } - // InputPixelType min,max; + //TO UNCOMMENT TO HAVE THE SAME MEAN NORMALIZATION FACTOR FOR EACH BAND + + // InputPixelType min,max; // max = (m_MaxComponentValue[m_RedChannelIndex] // +m_MaxComponentValue[m_GreenChannelIndex] -// +m_MaxComponentValue[m_BlueChannelIndex])/2; +// +m_MaxComponentValue[m_BlueChannelIndex])/3; // min = (m_MinComponentValue[m_RedChannelIndex] // +m_MinComponentValue[m_GreenChannelIndex] -// +m_MinComponentValue[m_BlueChannelIndex])/2; - - - // otbMsgDebugMacro(<<"Normalization between: "<<m_MinComponentValue<<" and "<<m_MaxComponentValue); +// +m_MinComponentValue[m_BlueChannelIndex])/3; +// otbMsgDebugMacro(<<"Normalization between: "<<m_MinComponentValue<<" and "<<m_MaxComponentValue); // for(unsigned int i = 1; i<nbComponents;++i) // { // if(min>m_MinComponentValue[i]) @@ -152,10 +154,11 @@ namespace otb // if(max<m_MaxComponentValue[i]) // max=m_MaxComponentValue[i]; // } - - // m_MinComponentValue.Fill(min); +// m_MinComponentValue.Fill(min); // m_MaxComponentValue.Fill(max); + // END + otbMsgDebugMacro(<<"Data min: "<<absolutMin<<", Data max: "<<absolutMax); otbMsgDebugMacro(<<"Normalization between: "<<m_MinComponentValue<<" and "<<m_MaxComponentValue); } @@ -219,7 +222,10 @@ namespace otb } // Create the quicklook m_Shrink->SetInput(m_InputImage); - m_ShrinkFactor = (size[0]/hscroll < size[1]/wscroll ? size[0]/hscroll : size[1]/wscroll)/2; + m_ShrinkFactor = static_cast<unsigned int>((size[0]/hscroll < size[1]/wscroll ? + static_cast<double>(size[0])/static_cast<double>(hscroll) + : static_cast<double>(size[1])/static_cast<double>(wscroll)) + /m_QuicklookRatioCoef); otbMsgDebugMacro("Shrink factor: "<<m_ShrinkFactor); m_Shrink->SetShrinkFactor(m_ShrinkFactor); typedef otb::FltkFilterWatcher WatcherType; @@ -380,7 +386,22 @@ namespace otb void ImageViewer<TPixel> ::Hide(void) - {} + { + Fl::check(); + if(m_UseScroll) + { + m_ScrollWindow->hide(); + m_ScrollWidget->hide(); + } + m_FullWindow->hide(); + m_FullWidget->hide(); + m_ZoomWindow->hide(); + m_ZoomWidget->hide(); + m_PixLocWindow->hide(); + m_PixLocOutput->hide(); + Fl::check(); + } + /// Update the display template <class TPixel> void diff --git a/Code/Visu/otbImageViewerFullWidget.h b/Code/Visu/otbImageViewerFullWidget.h index ebc544b15a..14903b38f1 100644 --- a/Code/Visu/otbImageViewerFullWidget.h +++ b/Code/Visu/otbImageViewerFullWidget.h @@ -141,6 +141,11 @@ class ITK_EXPORT ImageViewerFullWidget m_Parent->ChangeZoomViewedRegion(newIndex); return 1; } + case FL_HIDE: + { + m_Parent->Hide(); + return 1; + } } return 0; } diff --git a/Code/Visu/otbImageViewerScrollWidget.h b/Code/Visu/otbImageViewerScrollWidget.h index c259d4fd3e..c0db4b10ab 100644 --- a/Code/Visu/otbImageViewerScrollWidget.h +++ b/Code/Visu/otbImageViewerScrollWidget.h @@ -107,6 +107,11 @@ class ITK_EXPORT ImageViewerScrollWidget m_MouseMoveCount++; return 1; } + case FL_HIDE: + { + m_Parent->Hide(); + return 1; + } } return 0; } diff --git a/Code/Visu/otbImageWidgetBase.txx b/Code/Visu/otbImageWidgetBase.txx index ef621c3a65..b76730d97f 100644 --- a/Code/Visu/otbImageWidgetBase.txx +++ b/Code/Visu/otbImageWidgetBase.txx @@ -276,18 +276,18 @@ ImageWidgetBase<TPixel> { min = m_MinComponentValues[channelIndex]; } - if(value>max) + if(value>=max) { return 255; } - else if(value<min) + else if(value<=min) { return 0; } else { - return static_cast<unsigned char>(255*static_cast<double>(value-min) + return static_cast<unsigned char>(255.*static_cast<double>(value-min) /static_cast<double>(max-min)); } } -- GitLab