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

TEST: Adding a new VariableDimensionHistogram generator inspired from the...

TEST: Adding a new VariableDimensionHistogram generator inspired from the fixed dimension ITK histogram generator
parent f3ec6326
No related branches found
No related tags found
No related merge requests found
......@@ -1289,6 +1289,20 @@ ADD_TEST(bfTvItkImagePCAShapeModelEstimatorTest ${BASICFILTERS_TESTS11}
${TEMP}/bfITKimagePCAShapeModelEstimatorTest_eigen_vectors3.tif
)
# ------- otb::ListSampleToVariableDimensionHistogramGenerator ----------------------------
ADD_TEST(bfTuListSampleToVariableDimensionHistogramGeneratorNew ${BASICFILTERS_TESTS11}
otbListSampleToVariableDimensionHistogramGeneratorNew)
ADD_TEST(bfTvListSampleToVariableDimensionHistogramGenerator ${BASICFILTERS_TESTS11}
--compare-ascii ${TOL}
${BASELINE_FILES}/bfTvListSampleToVariableDimensionHistogramGeneratorOutput.txt
${TEMP}/bfTvListSampleToVariableDimensionHistogramGeneratorOutput.txt
otbListSampleToVariableDimensionHistogramGenerator
${INPUTDATA}/couleurs.tif
${TEMP}/bfTvListSampleToVariableDimensionHistogramGeneratorOutput.txt
10 1
)
# A enrichir
SET(BasicFilters_SRCS1
......@@ -1467,6 +1481,8 @@ otbNormalizeInnerProductPCAImageFilterNew.cxx
otbNormalizeInnerProductPCAImageFilter.cxx
otbInnerProductPCAImageFilter.cxx
otbInnerProductPCAImageFilterNew.cxx
otbListSampleToVariableDimensionHistogramGeneratorNew.cxx
otbListSampleToVariableDimensionHistogramGenerator.cxx
)
......
......@@ -45,4 +45,6 @@ void RegisterTests()
REGISTER_TEST(otbNormalizeInnerProductPCAImageFilter);
REGISTER_TEST(otbInnerProductPCAImageFilterNew);
REGISTER_TEST(otbInnerProductPCAImageFilter);
REGISTER_TEST(otbListSampleToVariableDimensionHistogramGeneratorNew);
REGISTER_TEST(otbListSampleToVariableDimensionHistogramGenerator);
}
/*=========================================================================
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.
=========================================================================*/
#include "otbVectorImage.h"
#include "itkListSample.h"
#include "otbListSampleToVariableDimensionHistogramGenerator.h"
#include "otbImageFileReader.h"
#include "itkImageRegionIterator.h"
int otbListSampleToVariableDimensionHistogramGenerator(int argc, char * argv[])
{
typedef double PixelType;
typedef otb::VectorImage<PixelType> VectorImageType;
typedef VectorImageType::PixelType VectorPixelType;
typedef itk::Statistics::ListSample<VectorPixelType> ListSampleType;
typedef otb::ListSampleToVariableDimensionHistogramGenerator
<ListSampleType,PixelType> HistogramGeneratorType;
typedef otb::ImageFileReader<VectorImageType> ReaderType;
// Instantiation
ReaderType::Pointer reader = ReaderType::New();
HistogramGeneratorType::Pointer generator = HistogramGeneratorType::New();
ListSampleType::Pointer ls = ListSampleType::New();
reader->SetFileName(argv[1]);
reader->Update();
itk::ImageRegionConstIterator<VectorImageType> it(reader->GetOutput(),reader->GetOutput()->GetLargestPossibleRegion());
for(it.GoToBegin();!it.IsAtEnd();++it)
{
ls->PushBack(it.Get());
}
HistogramGeneratorType::HistogramSizeType nbBins(reader->GetOutput()->GetNumberOfComponentsPerPixel());
nbBins.Fill(atoi(argv[3]));
float mscale = atof(argv[4]);
generator->SetListSample(ls);
generator->SetNumberOfBins(nbBins);
generator->SetMarginalScale(mscale);
generator->Update();
std::ofstream ofs;
ofs.open(argv[2]);
for(unsigned int comp = 0; comp<reader->GetOutput()->GetNumberOfComponentsPerPixel();++comp)
{
ofs<<"Channel: "<<comp<<" histogram: "<<std::endl;
for(unsigned int bin = 0; bin < nbBins[comp];++bin)
{
ofs<<generator->GetOutput()->GetFrequency(bin,comp)<<"\t";
}
ofs<<std::endl;
}
ofs.close();
return EXIT_SUCCESS;
}
/*=========================================================================
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.
=========================================================================*/
#include "otbVectorImage.h"
#include "itkListSample.h"
#include "otbListSampleToVariableDimensionHistogramGenerator.h"
int otbListSampleToVariableDimensionHistogramGeneratorNew(int argc, char * argv[])
{
typedef double PixelType;
typedef otb::VectorImage<PixelType> VectorImageType;
typedef VectorImageType::PixelType VectorPixelType;
typedef itk::Statistics::ListSample<VectorPixelType> ListSampleType;
typedef otb::ListSampleToVariableDimensionHistogramGenerator
<ListSampleType,PixelType> HistogramGeneratorType;
// Instantiation
HistogramGeneratorType::Pointer generator = HistogramGeneratorType::New();
return EXIT_SUCCESS;
}
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