modifié : MakefileNoOTB

modifié :         include/Appli/Option.hpp
	modifié :         include/ArrayTree/ArrayTreeBuilder.hpp
	modifié :         include/ArrayTree/ArrayTreeBuilder.tpp
	modifié :         include/ArrayTree/triskeleArrayTreeBase.hpp
	modifié :         include/TreeStats.hpp
	modifié :         include/TreeStats.tpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/ArrayTree/triskeleArrayTreeBase.cpp
	modifié :         src/TreeStats.cpp
	modifié :         src/apGenerator.cpp
This commit is contained in:
Git Merciol 2018-02-27 08:50:55 +01:00
parent 5eaab87185
commit 22206596ad
11 changed files with 45 additions and 38 deletions

View File

@ -13,8 +13,8 @@ TST_SRC = $(patsubst %, $(CPP_DIR)/%.cpp, $(TST_PRG))
TST_OUT = $(patsubst %, $(OUT_DIR)/%, $(TST_PRG))
## FLAGS ###############################
#DFLAGS = -O2
DFLAGS = -g -DENABLE_LOG -DNO_OTB # -DSMART_LOG # -DTHREAD_DISABLE
DFLAGS = -O2 -DNDEBUG -DBOOST_DISABLE_ASSERTS -DNO_OTB
#DFLAGS = -g -DENABLE_LOG -DNO_OTB # -DSMART_LOG # -DTHREAD_DISABLE
IFLAGS = $(DFLAGS) -MMD -I$(HPP_DIR)
LFLAGS = -L$(LIB_DIR) -ltriskele -lstdc++ -lpthread -lboost_system -lboost_chrono -lboost_thread -lboost_program_options -lboost_date_time -lboost_serialization -lboost_filesystem -lboost_unit_test_framework -lgdal
CC = g++

View File

@ -26,7 +26,7 @@ namespace otb {
vector<DimImg> areaThresholds;
vector<double> sdThresholds, moiThresholds;
unsigned int coreCount = boost::thread::hardware_concurrency ();
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false;
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false, alphaTreeFlag = false;
bool oneBand = false;
Option ();

View File

@ -28,7 +28,7 @@ namespace otb {
unsigned int coreCount;
const Raster<PixelT> &raster;
const GraphWalker &graphWalker;
TreeType type;
TreeType treeType;
bool countingFlag;
Leader leaders;

View File

@ -11,7 +11,7 @@ ArrayTreeBuilder<WeightT, PixelT>::ArrayTreeBuilder (Raster<PixelT> &raster, con
coreCount (boost::thread::hardware_concurrency ()),
raster (raster),
graphWalker (graphWalker),
type (treeType),
treeType (treeType),
countingFlag (countingSort),
compWeights (nullptr),
childCountRec (nullptr),
@ -40,7 +40,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
compWeights = weightAttributes.getValues ();
auto start = high_resolution_clock::now ();
switch (type) {
switch (treeType) {
case MIN:
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
@ -50,11 +50,14 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
case TOS:
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
break;
case ALPHA:
buildTree (tree, DiffWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
default:
cerr << "*** unknown tree type: " << type << endl;
cerr << "*** unknown tree type: " << treeType << endl;
}
globalTreeStats.addTime (buildTreeStats, duration_cast<duration<double> > (high_resolution_clock::now ()-start).count ());
globalTreeStats.addDim ((treeType) type, leafCount, nodeCount-leafCount);
globalTreeStats.addDim (treeType, leafCount, nodeCount-leafCount);
weightAttributes.setWeightBounds (tree);
leaders.free ();
@ -69,7 +72,7 @@ inline void
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles) {
DEF_LOG ("ArrayTreeBuilder::setAttributProfiles", "");
attributeProfiles.updateTranscient ();
switch (type) {
switch (treeType) {
case MIN:
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
@ -79,8 +82,11 @@ ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT
case TOS:
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
break;
case ALPHA:
setAttributProfiles (attributeProfiles, DiffWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
default:
cerr << "*** unknown tree type: " << type << endl;
cerr << "*** unknown tree type: " << treeType << endl;
}
}
@ -446,6 +452,10 @@ ArrayTreeBuilder<WeightT, PixelT>::connectComp (DimImg newComp, DimImg topA, Dim
if (topB == DimImg_MAX)
swap (topA, topB);
// XXX >>> test alpha
// if (topB == DimImg_MAX)
// return;
// XXX <<<
BOOST_ASSERT (topB != DimImg_MAX);
if (topA != DimImg_MAX && weightFunct.isWeightInf (compWeights[topA], compWeights[topB]))
swap (topA, topB);

View File

@ -26,14 +26,7 @@ namespace otb {
enum TileItem { Surface, Horizontal, Vertical };
/* Définit le type d'arbre à construire */
enum TreeType { MIN, MAX, TOS, /*ALPHA*/};
enum treeType {
minE,
maxE,
tosE,
treeTypeCount
};
enum TreeType { MIN, MAX, TOS, ALPHA, TreeTypeCard};
/*! Définit les noms des connectivités (utile pour le debug) */
extern std::string connectivityName[];
@ -42,7 +35,7 @@ namespace otb {
extern std::string tileItemName[];
/*! Définit les noms des arbres (utile pour le debug) */
extern std::string treeName[];
extern std::string treeTypeLabels[];
/*!
* Opérateur de flux sur les connectivités

View File

@ -29,7 +29,7 @@ namespace otb {
ba::tag::min,
ba::tag::max> > TreeStatsDouble;
enum statsIdxType {
enum TimeType {
buildTreeStats,
areaStats,
averageStats,
@ -42,21 +42,21 @@ namespace otb {
writeStats,
allStats,
statsIdxTypeCount
TimeTypeCard
};
class TreeStats {
public :
//void reset ();
inline void addDim (const treeType &type, const DimImg& leafCount, const DimImg& compCount);
inline void addTime (const statsIdxType &type, const double &duration);
inline void addDim (const TreeType &treeType, const DimImg& leafCount, const DimImg& compCount);
inline void addTime (const TimeType &timeType, const double &duration);
ostream &printDim (ostream &out);
ostream &printTime (ostream &out);
private :
ostream &printDim (ostream &out, const TreeStatsDim stats[], const string &msg);
TreeStatsDim leavesStats[treeTypeCount], compStats[treeTypeCount];
TreeStatsDouble timeStats[statsIdxTypeCount];
TreeStatsDim leavesStats[TreeTypeCard], compStats[TreeTypeCard];
TreeStatsDouble timeStats[TimeTypeCard];
};
static TreeStats globalTreeStats;

View File

@ -3,14 +3,14 @@
// ========================================
inline void
TreeStats::addDim (const treeType &type, const DimImg& leafCount, const DimImg& compCount) {
leavesStats[type] (leafCount);
compStats[type] (compCount);
TreeStats::addDim (const TreeType &treeType, const DimImg& leafCount, const DimImg& compCount) {
leavesStats[treeType] (leafCount);
compStats[treeType] (compCount);
}
inline void
TreeStats::addTime (const statsIdxType &type, const double &duration) {
timeStats[type] (duration);
TreeStats::addTime (const TimeType &timeType, const double &duration) {
timeStats[timeType] (duration);
}
// ========================================

View File

@ -121,6 +121,8 @@ Option::parse (int argc, char** argv) {
("use-the-force-luke", po::bool_switch (&useTheForceLuke), "display hidded options")
("tree-core-count", po::value<unsigned int> (&coreCount), "thread used to build tree (default hardware value)")
("one-band", po::bool_switch (&oneBand), "split all bands, one band per image")
("alpha-tree", po::bool_switch (&alphaTreeFlag), "build alpha-tree")
// ("no-border", po::bool_switch (&options.noBorder), "build tree with all pixels (included no-data)")
// ("dap", po::bool_switch (&options.dapFlag), "produce DAP rather than AP")
// ("use-all-orig", po::bool_switch (&options.useAllOrigFlag), "force use all original band")

View File

@ -13,6 +13,6 @@ otb::triskele::arrayTree::tileItemName[] = {
};
std::string
otb::triskele::arrayTree::treeName[] = {
otb::triskele::arrayTree::treeTypeLabels[] = {
"min", "max", "tos"
};

View File

@ -8,7 +8,7 @@ using namespace otb::triskele;
using namespace std;
// ========================================
static string timeStatsLabels [statsIdxTypeCount] = {
static string timeTypeLabels [TimeTypeCard] = {
"build tree",
"area",
"average",
@ -51,10 +51,10 @@ TreeStats::printDim (ostream &out, const TreeStatsDim stats[], const string &msg
<< setw (9) << left << "Mean" << "\t"
<< setw (9) << left << "Min" << "\t"
<< setw (9) << left << "Max" << endl;
for (unsigned int i = 0; i < treeTypeCount; ++i) {
for (unsigned int i = 0; i < TreeTypeCard; ++i) {
if (!ba::count (stats[i]))
continue;
cout << setw (11) << right << treeName [i] << "\t"
cout << setw (11) << right << treeTypeLabels [i] << "\t"
<< setw (3) << ba::count (stats[i]) << "\t"
<< setw (9) << DimImg (ba::mean (stats[i])) << "\t"
<< setw (9) << ba::min (stats[i]) << "\t"
@ -67,7 +67,7 @@ TreeStats::printDim (ostream &out, const TreeStatsDim stats[], const string &msg
ostream &
TreeStats::printDim (ostream &out) {
bool empty = true;
for (unsigned int i = 0; i < treeTypeCount; ++i)
for (unsigned int i = 0; i < TreeTypeCard; ++i)
if (!(empty = !ba::count (leavesStats[i])))
break;
if (empty)
@ -79,7 +79,7 @@ TreeStats::printDim (ostream &out) {
ostream &
TreeStats::printTime (ostream &out) {
bool empty = true;
for (unsigned int i = 0; i < statsIdxTypeCount; ++i)
for (unsigned int i = 0; i < TimeTypeCard; ++i)
if (!(empty = !ba::count (timeStats[i])))
break;
if (empty)
@ -91,10 +91,10 @@ TreeStats::printTime (ostream &out) {
<< setw (15) << left << "Mean" << "\t"
<< setw (15) << left << "Min" << "\t"
<< setw (15) << left << "Max" << endl;
for (unsigned int i = 0; i < statsIdxTypeCount; ++i) {
for (unsigned int i = 0; i < TimeTypeCard; ++i) {
if (!ba::count (timeStats[i]))
continue;
cout << setw (11) << right << timeStatsLabels[i] << "\t"
cout << setw (11) << right << timeTypeLabels[i] << "\t"
<< ns2string (ba::sum (timeStats[i])) << "\t" << setw (3) << ba::count (timeStats[i]) << "\t"
<< ns2string (ba::mean (timeStats[i])) << "\t"
<< ns2string (ba::min (timeStats[i])) << "\t"

View File

@ -61,6 +61,8 @@ void apGenerator (Option &option) {
treeTypes.push_back (MAX);
if (option.tosTreeFlag)
treeTypes.push_back (TOS);
if (option.alphaTreeFlag)
treeTypes.push_back (ALPHA);
DimChanel treeTypesCard = treeTypes.size ();
if (!treeTypesCard)
cerr << "*** no tree type ! => copy mode" << endl;