modifié : MakefileNoOTB

modifié :         include/ArrayTree/ArrayTreeBuilder.hpp
	modifié :         include/ArrayTree/ArrayTreeBuilder.tpp
	modifié :         include/Attributes/AreaAttributes.hpp
	modifié :         include/Attributes/AreaAttributes.tpp
	modifié :         include/Attributes/AverageAttributes.hpp
	modifié :         include/Attributes/AverageAttributes.tpp
	modifié :         include/Attributes/MoIAttributes.hpp
	modifié :         include/Attributes/MoIAttributes.tpp
	modifié :         include/Attributes/SDAttributes.hpp
	modifié :         include/Attributes/SDAttributes.tpp
	modifié :         include/Attributes/XYAttributes.hpp
	modifié :         include/Attributes/XYAttributes.tpp
	modifié :         src/apGenerator.cpp
This commit is contained in:
Git Merciol 2018-02-26 13:49:19 +01:00
parent db7037f624
commit 77c4b5fd0b
14 changed files with 54 additions and 8 deletions

View File

@ -53,9 +53,9 @@ apGenerator: $(TST_OUT)
## DEPENDS #############################
ALL_OUT = $(TST_OUT)
ALL_OBJ = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/Option.o $(OBJ_DIR)/Selected.o
ALL_OBJ = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/TreeStats.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/Option.o $(OBJ_DIR)/Selected.o
ALL_OBJ_XML = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/XMLTreeBuilder.o $(OBJ_DIR)/Option.o $(OBJ_DIR)/Selected.o
ALL_OBJ_XML = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/TreeStats.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/XMLTreeBuilder.o $(OBJ_DIR)/Option.o $(OBJ_DIR)/Selected.o
DEPENDS = ${ALL_OUT:=.d} ${ALL_OBJ:.o=.d}
-include ${DEPENDS}

View File

@ -5,6 +5,8 @@
#include <iostream>
#endif // ENABLE_LOG
#include <boost/chrono.hpp>
#include "triskeleDebug.hpp"
#include "triskeleSort.hpp"
#include "triskeleDealThreads.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_ARRAY_TREE_BUILDER_TPP
#define _OTB_TRISKELE_ARRAY_TREE_BUILDER_TPP
using namespace boost::chrono;
// ========================================
template<typename WeightT, typename PixelT>
inline
@ -37,6 +39,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
newCompId = leaders.getLeaders ();
compWeights = weightAttributes.getValues ();
auto start = high_resolution_clock::now ();
switch (type) {
case MIN:
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
@ -50,6 +53,9 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
default:
cerr << "*** unknown tree type: " << type << endl;
}
globalTreeStats.addTime (buildTreeStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
globalTreeStats.addDim ((treeType) type, leafCount, nodeCount-leafCount);
weightAttributes.setWeightBounds (tree);
leaders.free ();
newCompId = nullptr;

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_AREA_ATTRIBUTES_HPP
#define _OTB_TRISKELE_AREA_ATTRIBUTES_HPP
#include <boost/chrono.hpp>
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_AREA_ATTRIBUTES_TPP
#define _OTB_TRISKELE_AREA_ATTRIBUTES_TPP
using namespace boost::chrono;
inline
AreaAttributes::AreaAttributes (const Tree &tree)
: CompAttributeC<DimImg> (tree) {
@ -15,11 +17,14 @@ template<typename PixelT>
inline void
AreaAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<DimImg> &thresholds) const {
auto start = high_resolution_clock::now ();
CompAttributeC<DimImg>::cut (allBands, attributeProfiles, 1, thresholds);
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
inline void
AreaAttributes::compute () {
auto start = high_resolution_clock::now ();
computeSameCompLevel ([this] (const DimImg &parentId) {
DimImg area = 0;
tree.forEachChildTI (parentId, [this, &area] (const bool &isLeaf, const DimImg &childId) {
@ -27,6 +32,7 @@ AreaAttributes::compute () {
});
CompAttribute<DimImg>::values [parentId] = area;
});
globalTreeStats.addTime (areaStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_AREA_ATTRIBUTES_TPP

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_AVERAGE_ATTRIBUTES_HPP
#define _OTB_TRISKELE_AVERAGE_ATTRIBUTES_HPP
#include <boost/chrono.hpp>
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"
#include "Attributes/AreaAttributes.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP
#define _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP
using namespace boost::chrono;
template<typename PixelT>
inline
AverageAttributes::AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes)
@ -15,6 +17,7 @@ AverageAttributes::~AverageAttributes () {
template<typename PixelT>
inline void
AverageAttributes::compute (const Raster<PixelT> &raster, const AreaAttributes &areaAttributes) {
auto start = high_resolution_clock::now ();
const PixelT *pixels = raster.getPixels ();
const DimImg *areas = areaAttributes.getValues ();
computeSameCompLevel ([this, &pixels, &areas] (const DimImg &parentId) {
@ -24,6 +27,7 @@ AverageAttributes::compute (const Raster<PixelT> &raster, const AreaAttributes &
});
CompAttribute<double>::values [parentId] = tmpAverage/areas[parentId];
});
globalTreeStats.addTime (averageStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_AVERAGE_ATTRIBUTES_TPP

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_MOI_ATTRIBUTES_HPP
#define _OTB_TRISKELE_MOI_ATTRIBUTES_HPP
#include <boost/chrono.hpp>
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_MOI_ATTRIBUTES_TPP
#define _OTB_TRISKELE_MOI_ATTRIBUTES_TPP
using namespace boost::chrono;
inline
MoIAttributes::MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes)
: CompAttributeC<double> (tree) {
@ -18,14 +20,17 @@ MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<P
DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ());
if (!thresholds.size ())
return;
auto start = high_resolution_clock::now ();
double maxValue = CompAttribute<double>::getMaxValue ();
cerr << "moi max value:" << maxValue << endl;
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
inline void
MoIAttributes::compute (const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes) {
auto start = high_resolution_clock::now ();
const AverageXY *xy = xyAttributes.getValues ();
const DimImg *areas = areaAttributes.getValues ();
computeSameCompLevel ([this, &xy, &areas] (const DimImg &parentId) {
@ -42,6 +47,7 @@ MoIAttributes::compute (const AreaAttributes &areaAttributes, const XYAttributes
const double card = areas[parentId];
CompAttribute<double>::values[parentId] = tmpMoI/(card*card);
});
globalTreeStats.addTime (moiStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_MOI_ATTRIBUTES_TPP

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_HPP
#define _OTB_TRISKELE_SD_ATTRIBUTES_HPP
#include <boost/chrono.hpp>
#include "triskeleDebug.hpp"
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_TPP
#define _OTB_TRISKELE_SD_ATTRIBUTES_TPP
using namespace boost::chrono;
inline
SDAttributes::SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
: CompAttributeC<double> (tree) {
@ -18,14 +20,17 @@ SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<Pi
DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ());
if (!thresholds.size ())
return;
auto start = high_resolution_clock::now ();
double maxValue = CompAttribute<double>::getMaxValue ();
cerr << "sd max value:" << maxValue << endl;
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
globalTreeStats.addTime (filteringStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
inline void
SDAttributes::compute (const AreaAttributes &areaAttributes) {
auto start = high_resolution_clock::now ();
const DimImg *areas = areaAttributes.getValues ();
computeSameCompLevel ([this, &areas] (const DimImg &parentId) {
double tmpSD = 0.;
@ -40,6 +45,7 @@ SDAttributes::compute (const AreaAttributes &areaAttributes) {
// XXX on peut virer pour gagner du temps et calculer SD*SD
CompAttribute<double>::values[parentId] = sqrt (CompAttribute<double>::values[parentId]);
});
globalTreeStats.addTime (sdStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_SD_ATTRIBUTES_TPP

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_XY_ATTRIBUTES_HPP
#define _OTB_TRISKELE_XY_ATTRIBUTES_HPP
#include <boost/chrono.hpp>
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"
#include "Attributes/AreaAttributes.hpp"

View File

@ -1,6 +1,8 @@
#ifndef _OTB_TRISKELE_XY_ATTRIBUTES_TPP
#define _OTB_TRISKELE_XY_ATTRIBUTES_TPP
using namespace boost::chrono;
inline
XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes)
: CompAttributeC<AverageXY> (tree) {
@ -13,6 +15,7 @@ XYAttributes::~XYAttributes () {
inline void
XYAttributes::compute (const AreaAttributes &areaAttributes) {
auto start = high_resolution_clock::now ();
DimImg const width = CompAttribute<AverageXY>::tree.getSize ().width;
const DimImg *areas = areaAttributes.getValues ();
computeSameCompLevel ([this, &width, &areas] (const DimImg &parentId) {
@ -29,6 +32,7 @@ XYAttributes::compute (const AreaAttributes &areaAttributes) {
CompAttribute<AverageXY>::values[parentId].x = tmpXY.x/areas[parentId];
CompAttribute<AverageXY>::values[parentId].y = tmpXY.y/areas[parentId];
});
globalTreeStats.addTime (xyStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
}
#endif // _OTB_TRISKELE_XY_ATTRIBUTES_TPP

View File

@ -5,6 +5,7 @@
#include "triskeleBase.hpp"
#include "Appli/Option.hpp"
#include "Tree.hpp"
#include "TreeStats.hpp"
#include "TreeBuilder.hpp"
#include "QuadTree/QuadTreeBuilder.hpp"
//#include "XMLTree/XMLTreeBuilder.hpp"
@ -33,13 +34,12 @@ using namespace otb::triskele::arrayTree;
template<typename PixelT>
inline void
writeOneBand (Option &option, PixelT *pixels, DimChanel band) {
writeBand (Option &option, PixelT *pixels, DimChanel band) {
if (!option.oneBand) {
option.outputImage.writeBand (pixels, band);
return;
}
string outputBaseName = boost::filesystem::path (option.outputImage.getFileName ()).replace_extension ("").string ();
//boost::filesystem::basename (option.outputImage.getFileName ());
string outputExtension = boost::filesystem::extension (option.outputImage.getFileName ());
ostringstream fileNameStream;
@ -79,7 +79,7 @@ void apGenerator (Option &option) {
DimChanel chanel = 0;
for (DimChanel band : option.selectedBand.getSet ()) {
option.inputImage.readBand (raster, band, option.topLeft, option.size);
writeOneBand (option, raster.getPixels (), chanel++);
writeBand (option, raster.getPixels (), chanel++);
for (TreeType treeType : treeTypes) {
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, treeType);
@ -93,25 +93,27 @@ void apGenerator (Option &option) {
if (option.areaThresholds.size ()) {
areaAttributes.cut (allBands, attributeProfiles, option.areaThresholds);
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
writeOneBand (option, &allBands[c][0], chanel);
writeBand (option, &allBands[c][0], chanel);
}
if (option.sdThresholds.size ()) {
SDAttributes sdAttributes (tree, areaAttributes);
sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);
for (DimChanel c = 0; c < option.sdThresholds.size (); ++c, ++chanel)
writeOneBand (option, &allBands[c][0], chanel);
writeBand (option, &allBands[c][0], chanel);
}
if (option.moiThresholds.size ()) {
XYAttributes xyAttributes (tree, areaAttributes);
MoIAttributes moiAttributes (tree, areaAttributes, xyAttributes);
moiAttributes.cut (allBands, attributeProfiles, option.moiThresholds);
for (DimChanel c = 0; c < option.moiThresholds.size (); ++c, ++chanel)
writeOneBand (option, &allBands[c][0], chanel);
writeBand (option, &allBands[c][0], chanel);
}
}
}
cerr << endl << "*** apGenerator done!" << endl;
globalTreeStats.printDim (cerr);
globalTreeStats.printTime (cerr);
}
int