Skip to content
Snippets Groups Projects
Commit ce30b2b9 authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

ENH : change image list to clean cplx to vector image caster

parent 9ec49910
Branches
Tags
No related merge requests found
......@@ -27,10 +27,7 @@
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbExtractROI.h"
#include "itkComplexToRealImageFilter.h"
#include "itkComplexToImaginaryImageFilter.h"
#include "otbImageList.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbComplexToVectorImageCastFilter.h"
int otbImageFileReaderRADComplexFloatExtract(int argc, char* argv[])
......@@ -48,18 +45,16 @@ int otbImageFileReaderRADComplexFloatExtract(int argc, char* argv[])
typedef otb::Image<OutputPixelType, Dimension> OutputCplxImageType;
typedef otb::Image<float, Dimension> OutputScalarImageType;
typedef otb::VectorImage<float, Dimension> OutputImageType;
typedef otb::ImageList<OutputScalarImageType> ImageListType;
typedef otb::ImageFileReader<InputImageType> ReaderType;
typedef otb::ImageFileWriter<OutputImageType> WriterType;
typedef itk::ComplexToRealImageFilter<OutputCplxImageType, OutputScalarImageType> RealExtractorType;
typedef itk::ComplexToImaginaryImageFilter<OutputCplxImageType
, OutputScalarImageType> ImaginaryExtractorType;
typedef otb::ImageListToVectorImageFilter<ImageListType, OutputImageType> ListToVectorImageFilterType;
typedef otb::ComplexToVectorImageCastFilter<OutputCplxImageType, OutputImageType> CasterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
CasterType::Pointer caster = CasterType::New();
reader->SetFileName(inputFilename);
writer->SetFileName(outputFilename);
......@@ -76,22 +71,9 @@ int otbImageFileReaderRADComplexFloatExtract(int argc, char* argv[])
extractROIFilter->SetSizeX(100);
extractROIFilter->SetSizeY(100);
// The rest of the code is here to translate the image complexe into
// a VectorImage of int which each channel is the real and imagynary part
RealExtractorType::Pointer realExt = RealExtractorType::New();
ImaginaryExtractorType::Pointer imgExt = ImaginaryExtractorType::New();
realExt->SetInput(extractROIFilter->GetOutput());
imgExt->SetInput(extractROIFilter->GetOutput());
ImageListType::Pointer imList = ImageListType::New();
imList->PushBack(realExt->GetOutput());
imList->PushBack(imgExt->GetOutput());
ListToVectorImageFilterType::Pointer listCaster = ListToVectorImageFilterType::New();
listCaster->SetInput(imList);
caster->SetInput(extractROIFilter->GetOutput());
writer->SetInput(listCaster->GetOutput());
writer->SetInput(caster->GetOutput());
writer->Update();
return EXIT_SUCCESS;
......
......@@ -24,10 +24,7 @@
#include "itkExtractImageFilter.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "itkComplexToRealImageFilter.h"
#include "itkComplexToImaginaryImageFilter.h"
#include "otbImageList.h"
#include "otbImageListToVectorImageFilter.h"
#include "otbComplexToVectorImageCastFilter.h"
int otbTerraSarCalibrationImageComplexFilterTest(int argc, char * argv[])
......@@ -37,25 +34,22 @@ int otbTerraSarCalibrationImageComplexFilterTest(int argc, char * argv[])
const bool useFastCalibration = atoi(argv[3]);
const bool resultsInDbs = atoi(argv[4]);
typedef std::complex<double> ComplexType;
typedef otb::Image<ComplexType, 2> ImageCplxType;
typedef otb::Image<double, 2> ImageScalarType;
typedef otb::VectorImage<double, 2> OutputImageType;
typedef otb::ImageList<ImageScalarType> ImageListType;
typedef std::complex<double> ComplexType;
typedef otb::Image<ComplexType, 2> ImageCplxType;
typedef otb::Image<double, 2> ImageScalarType;
typedef otb::VectorImage<double, 2> OutputImageType;
typedef otb::ImageFileReader<ImageCplxType> ReaderType;
typedef otb::ImageFileWriter<OutputImageType> WriterType;
typedef otb::TerraSarCalibrationImageFilter<ImageCplxType, ImageCplxType> FilterType;
typedef itk::ExtractImageFilter<ImageCplxType, ImageCplxType> ExtractorType;
typedef itk::ComplexToRealImageFilter<ImageCplxType, ImageScalarType> RealExtractorType;
typedef itk::ComplexToImaginaryImageFilter<ImageCplxType, ImageScalarType> ImaginaryExtractorType;
typedef otb::ImageListToVectorImageFilter<ImageListType, OutputImageType> ListToVectorImageFilterType;
typedef otb::ImageFileReader<ImageCplxType> ReaderType;
typedef otb::ImageFileWriter<OutputImageType> WriterType;
typedef otb::TerraSarCalibrationImageFilter<ImageCplxType, ImageCplxType> FilterType;
typedef itk::ExtractImageFilter<ImageCplxType, ImageCplxType> ExtractorType;
typedef otb::ComplexToVectorImageCastFilter<ImageCplxType, OutputImageType> CasterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
FilterType::Pointer filter = FilterType::New();
ExtractorType::Pointer extractor = ExtractorType::New();
CasterType::Pointer caster = CasterType::New();
reader->SetFileName(inputFileName);
writer->SetFileName(outputFileName);
......@@ -66,10 +60,6 @@ int otbTerraSarCalibrationImageComplexFilterTest(int argc, char * argv[])
filter->SetUseFastCalibration(useFastCalibration);
filter->SetResultsInDecibels(resultsInDbs);
// The rest of the code is here to translate the image complexe into
// a VectorImage of int which each channel is the real and imagynary part
RealExtractorType::Pointer realExt = RealExtractorType::New();
ImaginaryExtractorType::Pointer imgExt = ImaginaryExtractorType::New();
if (argc == 9)
{
......@@ -85,23 +75,15 @@ int otbTerraSarCalibrationImageComplexFilterTest(int argc, char * argv[])
extractor->SetExtractionRegion(region);
extractor->SetInput(filter->GetOutput());
realExt->SetInput(extractor->GetOutput());
imgExt->SetInput(extractor->GetOutput());
caster->SetInput(extractor->GetOutput());
}
else
{
realExt->SetInput(filter->GetOutput());
imgExt->SetInput(filter->GetOutput());
caster->SetInput(filter->GetOutput());
}
ImageListType::Pointer imList = ImageListType::New();
imList->PushBack(realExt->GetOutput());
imList->PushBack(imgExt->GetOutput());
ListToVectorImageFilterType::Pointer listCaster = ListToVectorImageFilterType::New();
listCaster->SetInput(imList);
writer->SetInput(listCaster->GetOutput());
writer->SetInput(caster->GetOutput());
writer->Update();
return EXIT_SUCCESS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment