/usr/include/OTB-5.8/otbWrapperComplexInputImageParameter.txx is in libotb-dev 5.8.0+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | /*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbWrapperComplexInputImageParameter_txx
#define otbWrapperComplexInputImageParameter_txx
#include "otbWrapperComplexInputImageParameter.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkCastImageFilter.h"
#include "otbImageToVectorImageCastFilter.h"
namespace otb
{
namespace Wrapper
{
template <class TOutputImage>
TOutputImage *
ComplexInputImageParameter::GetImage()
{
// Used m_PreviousFileName because if not, when the user call twice GetImage,
// it without changing the filename, it returns 2 different
// image pointers
// Only one image type can be used
// 2 cases : the user set a filename vs. the user set an image
if (m_UseFilename)
{
if( m_PreviousFileName!=m_FileName && !m_FileName.empty() )
{
//////////////////////// Filename case:
// A new valid filename has been given : a reader is created
m_PreviousFileName = m_FileName;
typedef otb::ImageFileReader<TOutputImage> ReaderType;
typename ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(m_FileName);
try
{
reader->UpdateOutputInformation();
}
catch(itk::ExceptionObject &)
{
this->ClearValue();
}
m_Image = reader->GetOutput();
m_Reader = reader;
// Pay attention, don't return m_Image because it is a ImageBase...
return reader->GetOutput();
}
else
{
// In this case, the reader and the image should already be there
if (m_Image.IsNull())
{
itkExceptionMacro("No input image or filename detected...");
}
else
{
// Check if the image type asked here is the same as the one used for the reader
if (dynamic_cast<TOutputImage*> (m_Image.GetPointer()))
{
return dynamic_cast<TOutputImage*> (m_Image.GetPointer());
}
else
{
itkExceptionMacro("Cannot ask a different image type");
}
}
}
}
else
{
//////////////////////// Image case:
if( m_Image.IsNull() )
{
itkExceptionMacro("No input image or filename detected...");
}
else
{
if (dynamic_cast<ComplexFloatVectorImageType*>(m_Image.GetPointer()))
{
return CastImage<ComplexFloatVectorImageType, TOutputImage>();
}
else if (dynamic_cast<ComplexDoubleVectorImageType*>(m_Image.GetPointer()))
{
return CastImage<ComplexDoubleVectorImageType, TOutputImage>();
}
else if (dynamic_cast<ComplexFloatImageType*>(m_Image.GetPointer()))
{
return CastImage<ComplexFloatImageType, TOutputImage>();
}
else if (dynamic_cast<ComplexDoubleImageType*>(m_Image.GetPointer()))
{
return CastImage<ComplexDoubleImageType, TOutputImage>();
}
else
{
itkExceptionMacro("Unknown image type");
}
}
}
}
template <class TComplexInputImage, class TOutputImage>
TOutputImage*
ComplexInputImageParameter::CastImage()
{
itkExceptionMacro("Cast from "<<typeid(TComplexInputImage).name()
<<" to "<<typeid(TOutputImage).name()<<" not authorized.");
}
template <class TComplexInputImage, class TOutputImage>
TOutputImage*
ComplexInputImageParameter::SimpleCastImage()
{
TComplexInputImage* realComplexInputImage = dynamic_cast<TComplexInputImage*>(m_Image.GetPointer());
typedef itk::CastImageFilter<TComplexInputImage, TOutputImage> CasterType;
typename CasterType::Pointer caster = CasterType::New();
caster->SetInput(realComplexInputImage);
caster->UpdateOutputInformation();
m_Image = caster->GetOutput();
m_Caster = caster;
return caster->GetOutput();
}
template <class TComplexInputImage, class TOutputImage>
TOutputImage*
ComplexInputImageParameter::CastVectorImageFromImage()
{
TComplexInputImage* realComplexInputImage = dynamic_cast<TComplexInputImage*>(m_Image.GetPointer());
typedef ImageToVectorImageCastFilter<TComplexInputImage, TOutputImage> CasterType;
typename CasterType::Pointer caster = CasterType::New();
caster->SetInput(realComplexInputImage);
caster->UpdateOutputInformation();
m_Image = caster->GetOutput();
m_Caster = caster;
return caster->GetOutput();
}
template <class TComplexInputImage>
void
ComplexInputImageParameter::SetImage(TComplexInputImage* image)
{
m_UseFilename = false;
m_Image = image;
}
} // End namespace Wrapper
} // End namespace otb
#endif
|