diff --git a/Code/Visu/otbImageViewer.h b/Code/Visu/otbImageViewer.h index e7a2cadb17024b8264d26b1ae35e79420489972f..bec51ab121799f2eddbbdf236b1994f5309adf09 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 025fa8cbb27e476c82e6790208ead517fa3d3348..8dac2a46f78b22dcc2778d8559a70fc94783bf54 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 ebc544b15a8525e0df19b37f6bc19b5e94eeddbb..14903b38f1897634b6eff9babc5d942ee99460e6 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 c259d4fd3eac2983c2425236bd05f5ba1ba9ca54..c0db4b10ab08e6abe89b521909e9c3ae02974d00 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 ef621c3a6509ac133abe5f7a56932b3c7d976b30..b76730d97fbafc735dc8c9fbbb97dd818a1792d3 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)); } }