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

ENH: Added support of zoom in and zoom out interpolator

parent 71d14588
No related branches found
No related tags found
No related merge requests found
......@@ -23,17 +23,13 @@ PURPOSE. See the above copyright notices for more information.
#include "otbImageList.h"
#include "itkInterpolateImageFunction.h"
#include "itkLinearInterpolateImageFunction.h"
#include "otbBSplineInterpolateImageFunction.h"
#include "itkVectorImageToImageAdaptor.h"
#include "otbVectorImageToImageListFilter.h"
#include "otbImage.h"
#include "itkWindowedSincInterpolateImageFunction.h"
#include "otbWindowedSincInterpolateImageGaussianFunction.h"
#include "otbWindowedSincInterpolateImageHammingFunction.h"
#include "itkZeroFluxNeumannBoundaryCondition.h"
#include <FL/gl.h>
#include "itkImageRegionSplitter.h"
#include "otbProlateInterpolateImageFunction.h"
namespace otb
{
......@@ -78,14 +74,6 @@ class ITK_EXPORT ImageAlternateViewer
typedef itk::InterpolateImageFunction<SingleImageType,double> InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointerType;
typedef itk::LinearInterpolateImageFunction<SingleImageType,double> DefaultInterpolatorType;
typedef BSplineInterpolateImageFunction<SingleImageType,double,double> BSplineInterpolatorType;
typedef itk::Function::HammingWindowFunction<4> WindowFunctionType;
typedef otb::Function::GaussianWindowFunction<> GaussianWindowType;
typedef itk::ZeroFluxNeumannBoundaryCondition<SingleImageType> ConditionType;
typedef itk::WindowedSincInterpolateImageFunction<SingleImageType,3,WindowFunctionType,ConditionType ,double> WindowedSincInterpolatorType;
typedef WindowedSincInterpolateImageGaussianFunction<SingleImageType,ConditionType> OtbWindowedSincInterpolatorType;
typedef ProlateInterpolateImageFunction<SingleImageType,ConditionType> ProlateInterpolatorType;
typedef itk::ImageRegionSplitter<2> SplitterType;
typedef typename SplitterType::Pointer SplitterPointerType;
......
......@@ -51,19 +51,8 @@ namespace otb
m_DecompositionFilter = VectorImageDecompositionFilterType::New();
typename BSplineInterpolatorType::Pointer bsplineInterpolator = BSplineInterpolatorType::New();
bsplineInterpolator->SetSplineOrder(3);
typename ProlateInterpolatorType::Pointer prolateInterpolator = ProlateInterpolatorType::New();
prolateInterpolator->SetRadius(8);
typename OtbWindowedSincInterpolatorType::Pointer otbwinsinc = OtbWindowedSincInterpolatorType::New();
otbwinsinc->SetRadius(8);
typename DefaultInterpolatorType::Pointer defaultInterpolator = DefaultInterpolatorType::New();
// m_ZoomInInterpolator = WindowedSincInterpolatorType::New();
m_ZoomInInterpolator=defaultInterpolator;
// m_ZoomInInterpolator=bsplineInterpolator;
m_ZoomOutInterpolator = defaultInterpolator;
m_SpacingZoomFactor=1;
......@@ -456,10 +445,15 @@ namespace otb
unsigned int numberOfSplits=1;
unsigned int optiCount = 0;
if(m_SpacingZoomFactor>0)
InterpolatorPointerType interpolator;
if(m_SpacingZoomFactor>1)
{
numberOfSplits=max((static_cast<unsigned int>(m_SpacingZoomFactor))*(static_cast<unsigned int>(m_SpacingZoomFactor)),1U);
interpolator = m_ZoomOutInterpolator;
}
else
{
interpolator = m_ZoomInInterpolator;
}
unsigned int splitterNumberOfSplits = m_Splitter->GetNumberOfSplits(m_BufferedRegion,numberOfSplits);
......@@ -519,8 +513,8 @@ namespace otb
}
else
{
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
interpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex));
if(interpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos));
}
......@@ -534,17 +528,17 @@ namespace otb
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>( m_ZoomInInterpolator->Evaluate(interpolatedPos));
interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos));
}
else
{
interpolatedValue = 0;
}
newBuffer[index+1] = Normalize(interpolatedValue,m_GreenChannelIndex);
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
interpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex));
if( interpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos));
interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos));
}
else
{
......@@ -757,9 +751,15 @@ namespace otb
interpolatedPos.Fill(0);
unsigned int numberOfSplits=1;
if(m_SpacingZoomFactor>0)
InterpolatorPointerType interpolator;
if(m_SpacingZoomFactor>1)
{
numberOfSplits=max((static_cast<unsigned int>(m_SpacingZoomFactor))*(static_cast<unsigned int>(m_SpacingZoomFactor)),1U);
interpolator = m_ZoomOutInterpolator;
}
else
{
interpolator = m_ZoomInInterpolator;
}
unsigned int splitterNumberOfSplits = m_Splitter->GetNumberOfSplits(region,numberOfSplits);
......@@ -826,10 +826,10 @@ namespace otb
for(unsigned int i = 0;i<splitRegion.GetSize()[0];++i)
{
// //std::cout<<interpolatedPos<<std::endl;
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
interpolator->SetInputImage(bandList->GetNthElement(m_RedChannelIndex));
if( interpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos));
interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos));
}
else
{
......@@ -838,20 +838,20 @@ namespace otb
result[index] = Normalize(interpolatedValue,m_RedChannelIndex);
if(rgb)
{
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
interpolator->SetInputImage(bandList->GetNthElement(m_GreenChannelIndex));
if( interpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>( m_ZoomInInterpolator->Evaluate(interpolatedPos));
interpolatedValue = static_cast<PixelType>( interpolator->Evaluate(interpolatedPos));
}
else
{
interpolatedValue = 0;
}
result[index+1] = Normalize(interpolatedValue,m_GreenChannelIndex);
m_ZoomInInterpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex));
if( m_ZoomInInterpolator->IsInsideBuffer(interpolatedPos))
interpolator->SetInputImage(bandList->GetNthElement(m_BlueChannelIndex));
if( interpolator->IsInsideBuffer(interpolatedPos))
{
interpolatedValue = static_cast<PixelType>(m_ZoomInInterpolator->Evaluate(interpolatedPos));
interpolatedValue = static_cast<PixelType>(interpolator->Evaluate(interpolatedPos));
}
else
{
......
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