Skip to content
Snippets Groups Projects
Commit 8e8f8cf2 authored by Jordi Inglada's avatar Jordi Inglada
Browse files

ENH: added Tv for rectangle matching

parent 2edc63e5
No related branches found
No related tags found
No related merge requests found
......@@ -1724,6 +1724,16 @@ ADD_TEST(raTvUrbanAreaDetectionImageFilter ${FEATUREEXTRACTION_TESTS14}
ADD_TEST(feTuRegionImageToRectangularPathListFilterNew ${FEATUREEXTRACTION_TESTS14}
otbRegionImageToRectangularPathListFilterNew)
ADD_TEST(feTvRegionImageToRectangularPathListFilter ${FEATUREEXTRACTION_TESTS14}
--compare-ascii ${EPS} ${BASELINE_FILES}/feRectangle.txt
${TEMP}/feRectangle.txt
otbRegionImageToRectangularPathListFilter
${INPUTDATA}/rectangle.png
${TEMP}/feRectangle.txt
0.9 #fit score
10) #minimum size
# A enrichir
SET(BasicFeatureExtraction_SRCS1
otbAlignImageToPath.cxx
......@@ -1880,6 +1890,7 @@ otbSFSTexturesImageFilterTest.cxx
otbUrbanAreaDetectionImageFilterNew.cxx
otbUrbanAreaDetectionImageFilter.cxx
otbRegionImageToRectangularPathListFilterNew.cxx
otbRegionImageToRectangularPathListFilter.cxx
)
......
......@@ -35,5 +35,6 @@ REGISTER_TEST(otbSFSTexturesImageFilterNew);
REGISTER_TEST(otbSFSTexturesImageFilterTest);
REGISTER_TEST(otbUrbanAreaDetectionImageFilterNew);
REGISTER_TEST(otbUrbanAreaDetectionImageFilter);
REGISTER_TEST(otbRegionImageToRectangularPathListFilterNew);
REGISTER_TEST(otbRegionImageToRectangularPathListFilterNew);
REGISTER_TEST(otbRegionImageToRectangularPathListFilter);
}
/*=========================================================================
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 "itkExceptionObject.h"
#include "otbRegionImageToRectangularPathListFilter.h"
#include "itkPolyLineParametricPath.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include <stdio.h>
#include <iostream>
int otbRegionImageToRectangularPathListFilter(int argc, char * argv[])
{
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
typedef unsigned short InputPixelType;
const unsigned int Dimension = 2;
typedef otb::Image< InputPixelType, Dimension > InputImageType;
typedef otb::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( inputFilename );
reader->Update();
typedef otb::PolyLineParametricPathWithValue< double, Dimension > PathType;
typedef otb::RegionImageToRectangularPathListFilter<InputImageType,PathType>
RectangleListFilterType;
RectangleListFilterType::Pointer rectangleFilter =
RectangleListFilterType::New();
rectangleFilter->SetInput( reader->GetOutput() );
rectangleFilter->SetMinimumFit(::atof(argv[3]));
rectangleFilter->SetMinimumSize(::atoi(argv[4]));
rectangleFilter->Update();
typedef RectangleListFilterType::OutputPathListType ListType;
ListType* pathList = rectangleFilter->GetOutput();
ListType::Iterator listIt = pathList->Begin();
FILE *file = fopen(outputFilename,"w");
if (file == NULL)
{
fprintf(stderr,"Error, can't open file");
exit(-1);
}
while(listIt != pathList->End())
{
for (PathType::VertexListType::ConstIterator vit = listIt.Get()->GetVertexList()->Begin();
vit != listIt.Get()->GetVertexList()->End();++vit)
{
double x = vit.Value()[0];
double y = vit.Value()[1];
fprintf(file,"%8.3f %8.3f\n",x,y);
}
double score = listIt.Get()->GetValue();
fprintf(file,"%8.3f\n",score);
++listIt;
}
fclose(file);
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