Skip to content
Snippets Groups Projects
Commit 503c7010 authored by Julien Michel's avatar Julien Michel
Browse files

BUG: (Visu Refactoring) Missing initialization

parent a2ce1e62
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "otbRenderingImageFilter.h" #include "otbRenderingImageFilter.h"
#include "itkExtractImageFilter.h" #include "itkExtractImageFilter.h"
#include "itkListSample.h" #include "itkListSample.h"
#include "otbListSampleToVariableDimensionHistogramGenerator.h" #include "otbListSampleToHistogramListGenerator.h"
#include "otbStandardRenderingFunction.h" #include "otbStandardRenderingFunction.h"
namespace otb namespace otb
...@@ -70,12 +70,13 @@ public: ...@@ -70,12 +70,13 @@ public:
typedef itk::VariableLengthVector<InternalPixelType> SampleType; typedef itk::VariableLengthVector<InternalPixelType> SampleType;
typedef itk::Statistics::ListSample<SampleType> ListSampleType; typedef itk::Statistics::ListSample<SampleType> ListSampleType;
typedef otb::ListSampleToVariableDimensionHistogramGenerator typedef otb::ListSampleToHistogramListGenerator
<ListSampleType,InternalPixelType,DFContainerType> HistogramFilterType; <ListSampleType,InternalPixelType,DFContainerType> HistogramFilterType;
typedef typename HistogramFilterType::HistogramType HistogramType; typedef typename HistogramFilterType::HistogramType HistogramType;
typedef typename HistogramType::Pointer HistogramPointerType; typedef typename HistogramType::Pointer HistogramPointerType;
typedef typename HistogramFilterType::HistogramListType HistogramListType;
typedef typename HistogramListType::Pointer HistogramListPointerType;
/** Rendering part */ /** Rendering part */
typedef RenderingImageFilter<TImage,TOutputImage> RenderingFilterType; typedef RenderingImageFilter<TImage,TOutputImage> RenderingFilterType;
typedef typename RenderingFilterType::Pointer RenderingFilterPointerType; typedef typename RenderingFilterType::Pointer RenderingFilterPointerType;
...@@ -110,9 +111,8 @@ public: ...@@ -110,9 +111,8 @@ public:
} }
itkGetObjectMacro(Quicklook,ImageType); itkGetObjectMacro(Quicklook,ImageType);
/** Set/Get the histogram list */ /** Get the histogram list */
itkSetObjectMacro(Histogram,HistogramType); itkGetObjectMacro(HistogramList,HistogramListType);
itkGetObjectMacro(Histogram,HistogramType);
/** Set/Get the rendering function */ /** Set/Get the rendering function */
void SetRenderingFunction(RenderingFunctionType * function) void SetRenderingFunction(RenderingFunctionType * function)
...@@ -209,7 +209,7 @@ private: ...@@ -209,7 +209,7 @@ private:
ImagePointerType m_Image; ImagePointerType m_Image;
/** Joint Histogram */ /** Joint Histogram */
HistogramPointerType m_Histogram; HistogramListPointerType m_HistogramList;
/** Rendering function */ /** Rendering function */
RenderingFunctionPointerType m_RenderingFunction; RenderingFunctionPointerType m_RenderingFunction;
......
...@@ -20,14 +20,15 @@ ...@@ -20,14 +20,15 @@
#include "itkImageRegionConstIterator.h" #include "itkImageRegionConstIterator.h"
#include "otbMacro.h" #include "otbMacro.h"
#include "itkTimeProbe.h"
namespace otb namespace otb
{ {
template <class TImage, class TOutputImage> template <class TImage, class TOutputImage>
ImageLayer<TImage,TOutputImage> ImageLayer<TImage,TOutputImage>
::ImageLayer() : m_Quicklook(), m_Image(), m_Histogram(), m_RenderingFunction(), ::ImageLayer() : m_Quicklook(), m_Image(), m_HistogramList(), m_RenderingFunction(),
m_NumberOfHistogramBins(20), m_AutoMinMax(true), m_AutoMinMaxUpToDate(false), m_AutoMinMaxQuantile(0.02), m_NumberOfHistogramBins(255), m_AutoMinMax(true), m_AutoMinMaxUpToDate(false), m_AutoMinMaxQuantile(0.02),
m_QuicklookRenderingFilter(), m_ExtractRenderingFilter(), m_ScaledExtractRenderingFilter(), m_QuicklookRenderingFilter(), m_ExtractRenderingFilter(), m_ScaledExtractRenderingFilter(),
m_ExtractFilter(), m_ScaledExtractFilter() m_ExtractFilter(), m_ScaledExtractFilter()
{ {
...@@ -91,17 +92,23 @@ ImageLayer<TImage,TOutputImage> ...@@ -91,17 +92,23 @@ ImageLayer<TImage,TOutputImage>
// Render quicklook // Render quicklook
if(this->GetHasQuicklook()) if(this->GetHasQuicklook())
{ {
otbMsgDevMacro(<<"ImageLayer::RenderImages(): Regenerating quicklook"); itk::TimeProbe probe;
probe.Start();
m_QuicklookRenderingFilter->Update(); m_QuicklookRenderingFilter->Update();
this->SetRenderedQuicklook(m_QuicklookRenderingFilter->GetOutput()); this->SetRenderedQuicklook(m_QuicklookRenderingFilter->GetOutput());
probe.Stop();
otbMsgDevMacro(<<"ImageLayer::RenderImages():"<<" ("<<this->GetName()<<")"<< " quicklook regenerated ("<<probe.GetMeanTime()<<" s.)");
} }
// If there are pixels to render // If there are pixels to render
if(this->GetExtractRegion().GetNumberOfPixels() > 0) if(this->GetExtractRegion().GetNumberOfPixels() > 0)
{ {
otbMsgDevMacro(<<"ImageLayer::RenderImages(): Regenerating extract"); itk::TimeProbe probe;
probe.Start();
m_ExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetExtractRegion()); m_ExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetExtractRegion());
m_ExtractRenderingFilter->Update(); m_ExtractRenderingFilter->Update();
this->SetRenderedExtract(m_ExtractRenderingFilter->GetOutput()); this->SetRenderedExtract(m_ExtractRenderingFilter->GetOutput());
probe.Stop();
otbMsgDevMacro(<<"ImageLayer::RenderImages():"<<" ("<<this->GetName()<<")"<< " extract regenerated ("<<probe.GetMeanTime()<<" s.)");
} }
else else
{ {
...@@ -111,11 +118,14 @@ ImageLayer<TImage,TOutputImage> ...@@ -111,11 +118,14 @@ ImageLayer<TImage,TOutputImage>
// If there are pixels to render // If there are pixels to render
if(this->GetScaledExtractRegion().GetNumberOfPixels() > 0) if(this->GetScaledExtractRegion().GetNumberOfPixels() > 0)
{ {
otbMsgDevMacro(<<"ImageLayer::RenderImages(): Regenerating scaled extract"); itk::TimeProbe probe;
probe.Start();
m_ScaledExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetScaledExtractRegion()); m_ScaledExtractRenderingFilter->GetOutput()->SetRequestedRegion(this->GetScaledExtractRegion());
m_ScaledExtractRenderingFilter->Update(); m_ScaledExtractRenderingFilter->Update();
this->SetRenderedScaledExtract(m_ScaledExtractRenderingFilter->GetOutput()); this->SetRenderedScaledExtract(m_ScaledExtractRenderingFilter->GetOutput());
this->SetHasScaledExtract(true); this->SetHasScaledExtract(true);
probe.Stop();
otbMsgDevMacro(<<"ImageLayer::RenderImages():"<<" ("<<this->GetName()<<")"<< " scaled extract regenerated ("<<probe.GetMeanTime()<<" s.)");
} }
else else
{ {
...@@ -143,9 +153,9 @@ ImageLayer<TImage,TOutputImage> ...@@ -143,9 +153,9 @@ ImageLayer<TImage,TOutputImage>
} }
// Check if we need to generate the histogram again // Check if we need to generate the histogram again
if( !m_Histogram || (histogramSource->GetUpdateMTime() < histogramSource->GetPipelineMTime()) ) if( !m_HistogramList || (histogramSource->GetUpdateMTime() < histogramSource->GetPipelineMTime()) )
{ {
otbMsgDevMacro(<<"ImageLayer::RenderHistogram(): Regenerating histogram due to pippeline update."); otbMsgDevMacro(<<"ImageLayer::RenderHistogram():"<<" ("<<this->GetName()<<")"<< " Regenerating histogram due to pippeline update.");
m_AutoMinMaxUpToDate = false; m_AutoMinMaxUpToDate = false;
// Update the histogram source // Update the histogram source
...@@ -167,24 +177,21 @@ ImageLayer<TImage,TOutputImage> ...@@ -167,24 +177,21 @@ ImageLayer<TImage,TOutputImage>
listSample->PushBack(it.Get()); listSample->PushBack(it.Get());
++it; ++it;
} }
otbMsgDevMacro(<<"ImageLayer::RenderHistogram() Sample list generated ("<<listSample->Size()<<" samples, "<<histogramSource->GetNumberOfComponentsPerPixel()<<" bands)"); otbMsgDevMacro(<<"ImageLayer::RenderHistogram()"<<" ("<<this->GetName()<<")"<< " Sample list generated ("<<listSample->Size()<<" samples, "<<histogramSource->GetNumberOfComponentsPerPixel()<<" bands)");
// Create the histogram generation filter // Create the histogram generation filter
typename HistogramFilterType::Pointer histogramFilter = HistogramFilterType::New(); typename HistogramFilterType::Pointer histogramFilter = HistogramFilterType::New();
histogramFilter->SetListSample(listSample); histogramFilter->SetListSample(listSample);
typename HistogramFilterType::HistogramSizeType binSizes(histogramSource->GetNumberOfComponentsPerPixel()); histogramFilter->SetNumberOfBins(m_NumberOfHistogramBins);
binSizes.Fill(m_NumberOfHistogramBins);
histogramFilter->SetNumberOfBins(binSizes);
// Generate // Generate
histogramFilter->Update(); histogramFilter->Update();
otbMsgDevMacro(<<"ImageLayer::RenderHistogram() Histogram has been updated"); otbMsgDevMacro(<<"ImageLayer::RenderHistogram()"<<" ("<<this->GetName()<<")"<< " Histogram has been updated");
// Retrieve the histogram // Retrieve the histogram
m_Histogram = histogramFilter->GetOutput(); m_HistogramList = histogramFilter->GetOutput();
} }
} }
...@@ -196,23 +203,23 @@ ImageLayer<TImage,TOutputImage> ...@@ -196,23 +203,23 @@ ImageLayer<TImage,TOutputImage>
if(!m_AutoMinMaxUpToDate) if(!m_AutoMinMaxUpToDate)
{ {
// Check for an existing histogram // Check for an existing histogram
if(m_Histogram.IsNull()) if(m_HistogramList.IsNull())
{ {
itkExceptionMacro(<<"Empty histogram, can not use auto min/max evaluation."); itkExceptionMacro(<<"Empty histogram, can not use auto min/max evaluation.");
} }
otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup(): Updating min/max from histogram"); otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup():"<<" ("<<this->GetName()<<")"<< " Updating min/max from histogram");
const unsigned int nbComps = m_Image->GetNumberOfComponentsPerPixel(); const unsigned int nbComps = m_Image->GetNumberOfComponentsPerPixel();
typename RenderingFunctionType::ExtremaVectorType min, max; typename RenderingFunctionType::ExtremaVectorType min, max;
otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup(): "<<nbComps<<" components, quantile= "<<100*m_AutoMinMaxQuantile<<" %"); otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup(): "<<" ("<<this->GetName()<<") "<<nbComps<<" components, quantile= "<<100*m_AutoMinMaxQuantile<<" %");
// For each components, use the histogram to compute min and max // For each components, use the histogram to compute min and max
for(unsigned int comp = 0; comp < nbComps;++comp) for(unsigned int comp = 0; comp < nbComps;++comp)
{ {
// Compute quantiles // Compute quantiles
min.push_back(m_Histogram->Quantile(comp,m_AutoMinMaxQuantile)); min.push_back(m_HistogramList->GetNthElement(comp)->Quantile(0,m_AutoMinMaxQuantile));
max.push_back(m_Histogram->Quantile(comp,1.-m_AutoMinMaxQuantile)); max.push_back(m_HistogramList->GetNthElement(comp)->Quantile(0,1-m_AutoMinMaxQuantile));
otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup(): component "<<comp<<", min= "<<min.back()<<", max= "<<max.back()); otbMsgDevMacro(<<"ImageLayer::AutoMinMaxRenderingFunctionSetup():"<<" ("<<this->GetName()<<")"<< " component "<<comp<<", min= "<<min.back()<<", max= "<<max.back());
} }
// Setup rendering function // Setup rendering function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment