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:
parent
5eaab87185
commit
22206596ad
@ -13,8 +13,8 @@ TST_SRC = $(patsubst %, $(CPP_DIR)/%.cpp, $(TST_PRG))
|
|||||||
TST_OUT = $(patsubst %, $(OUT_DIR)/%, $(TST_PRG))
|
TST_OUT = $(patsubst %, $(OUT_DIR)/%, $(TST_PRG))
|
||||||
|
|
||||||
## FLAGS ###############################
|
## FLAGS ###############################
|
||||||
#DFLAGS = -O2
|
DFLAGS = -O2 -DNDEBUG -DBOOST_DISABLE_ASSERTS -DNO_OTB
|
||||||
DFLAGS = -g -DENABLE_LOG -DNO_OTB # -DSMART_LOG # -DTHREAD_DISABLE
|
#DFLAGS = -g -DENABLE_LOG -DNO_OTB # -DSMART_LOG # -DTHREAD_DISABLE
|
||||||
IFLAGS = $(DFLAGS) -MMD -I$(HPP_DIR)
|
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
|
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++
|
CC = g++
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace otb {
|
|||||||
vector<DimImg> areaThresholds;
|
vector<DimImg> areaThresholds;
|
||||||
vector<double> sdThresholds, moiThresholds;
|
vector<double> sdThresholds, moiThresholds;
|
||||||
unsigned int coreCount = boost::thread::hardware_concurrency ();
|
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;
|
bool oneBand = false;
|
||||||
|
|
||||||
Option ();
|
Option ();
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace otb {
|
|||||||
unsigned int coreCount;
|
unsigned int coreCount;
|
||||||
const Raster<PixelT> &raster;
|
const Raster<PixelT> &raster;
|
||||||
const GraphWalker &graphWalker;
|
const GraphWalker &graphWalker;
|
||||||
TreeType type;
|
TreeType treeType;
|
||||||
bool countingFlag;
|
bool countingFlag;
|
||||||
Leader leaders;
|
Leader leaders;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ ArrayTreeBuilder<WeightT, PixelT>::ArrayTreeBuilder (Raster<PixelT> &raster, con
|
|||||||
coreCount (boost::thread::hardware_concurrency ()),
|
coreCount (boost::thread::hardware_concurrency ()),
|
||||||
raster (raster),
|
raster (raster),
|
||||||
graphWalker (graphWalker),
|
graphWalker (graphWalker),
|
||||||
type (treeType),
|
treeType (treeType),
|
||||||
countingFlag (countingSort),
|
countingFlag (countingSort),
|
||||||
compWeights (nullptr),
|
compWeights (nullptr),
|
||||||
childCountRec (nullptr),
|
childCountRec (nullptr),
|
||||||
@ -40,7 +40,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
|
|||||||
compWeights = weightAttributes.getValues ();
|
compWeights = weightAttributes.getValues ();
|
||||||
|
|
||||||
auto start = high_resolution_clock::now ();
|
auto start = high_resolution_clock::now ();
|
||||||
switch (type) {
|
switch (treeType) {
|
||||||
case MIN:
|
case MIN:
|
||||||
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
@ -50,11 +50,14 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
|
|||||||
case TOS:
|
case TOS:
|
||||||
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
||||||
break;
|
break;
|
||||||
|
case ALPHA:
|
||||||
|
buildTree (tree, DiffWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
|
break;
|
||||||
default:
|
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.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);
|
weightAttributes.setWeightBounds (tree);
|
||||||
leaders.free ();
|
leaders.free ();
|
||||||
@ -69,7 +72,7 @@ inline void
|
|||||||
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles) {
|
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles) {
|
||||||
DEF_LOG ("ArrayTreeBuilder::setAttributProfiles", "");
|
DEF_LOG ("ArrayTreeBuilder::setAttributProfiles", "");
|
||||||
attributeProfiles.updateTranscient ();
|
attributeProfiles.updateTranscient ();
|
||||||
switch (type) {
|
switch (treeType) {
|
||||||
case MIN:
|
case MIN:
|
||||||
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
break;
|
break;
|
||||||
@ -79,8 +82,11 @@ ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT
|
|||||||
case TOS:
|
case TOS:
|
||||||
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
|
||||||
break;
|
break;
|
||||||
|
case ALPHA:
|
||||||
|
setAttributProfiles (attributeProfiles, DiffWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
|
||||||
|
break;
|
||||||
default:
|
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)
|
if (topB == DimImg_MAX)
|
||||||
swap (topA, topB);
|
swap (topA, topB);
|
||||||
|
// XXX >>> test alpha
|
||||||
|
// if (topB == DimImg_MAX)
|
||||||
|
// return;
|
||||||
|
// XXX <<<
|
||||||
BOOST_ASSERT (topB != DimImg_MAX);
|
BOOST_ASSERT (topB != DimImg_MAX);
|
||||||
if (topA != DimImg_MAX && weightFunct.isWeightInf (compWeights[topA], compWeights[topB]))
|
if (topA != DimImg_MAX && weightFunct.isWeightInf (compWeights[topA], compWeights[topB]))
|
||||||
swap (topA, topB);
|
swap (topA, topB);
|
||||||
|
|||||||
@ -26,14 +26,7 @@ namespace otb {
|
|||||||
enum TileItem { Surface, Horizontal, Vertical };
|
enum TileItem { Surface, Horizontal, Vertical };
|
||||||
|
|
||||||
/* Définit le type d'arbre à construire */
|
/* Définit le type d'arbre à construire */
|
||||||
enum TreeType { MIN, MAX, TOS, /*ALPHA*/};
|
enum TreeType { MIN, MAX, TOS, ALPHA, TreeTypeCard};
|
||||||
|
|
||||||
enum treeType {
|
|
||||||
minE,
|
|
||||||
maxE,
|
|
||||||
tosE,
|
|
||||||
treeTypeCount
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! Définit les noms des connectivités (utile pour le debug) */
|
/*! Définit les noms des connectivités (utile pour le debug) */
|
||||||
extern std::string connectivityName[];
|
extern std::string connectivityName[];
|
||||||
@ -42,7 +35,7 @@ namespace otb {
|
|||||||
extern std::string tileItemName[];
|
extern std::string tileItemName[];
|
||||||
|
|
||||||
/*! Définit les noms des arbres (utile pour le debug) */
|
/*! 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
|
* Opérateur de flux sur les connectivités
|
||||||
|
|||||||
@ -29,7 +29,7 @@ namespace otb {
|
|||||||
ba::tag::min,
|
ba::tag::min,
|
||||||
ba::tag::max> > TreeStatsDouble;
|
ba::tag::max> > TreeStatsDouble;
|
||||||
|
|
||||||
enum statsIdxType {
|
enum TimeType {
|
||||||
buildTreeStats,
|
buildTreeStats,
|
||||||
areaStats,
|
areaStats,
|
||||||
averageStats,
|
averageStats,
|
||||||
@ -42,21 +42,21 @@ namespace otb {
|
|||||||
writeStats,
|
writeStats,
|
||||||
allStats,
|
allStats,
|
||||||
|
|
||||||
statsIdxTypeCount
|
TimeTypeCard
|
||||||
};
|
};
|
||||||
|
|
||||||
class TreeStats {
|
class TreeStats {
|
||||||
public :
|
public :
|
||||||
//void reset ();
|
//void reset ();
|
||||||
inline void addDim (const treeType &type, const DimImg& leafCount, const DimImg& compCount);
|
inline void addDim (const TreeType &treeType, const DimImg& leafCount, const DimImg& compCount);
|
||||||
inline void addTime (const statsIdxType &type, const double &duration);
|
inline void addTime (const TimeType &timeType, const double &duration);
|
||||||
ostream &printDim (ostream &out);
|
ostream &printDim (ostream &out);
|
||||||
ostream &printTime (ostream &out);
|
ostream &printTime (ostream &out);
|
||||||
private :
|
private :
|
||||||
ostream &printDim (ostream &out, const TreeStatsDim stats[], const string &msg);
|
ostream &printDim (ostream &out, const TreeStatsDim stats[], const string &msg);
|
||||||
|
|
||||||
TreeStatsDim leavesStats[treeTypeCount], compStats[treeTypeCount];
|
TreeStatsDim leavesStats[TreeTypeCard], compStats[TreeTypeCard];
|
||||||
TreeStatsDouble timeStats[statsIdxTypeCount];
|
TreeStatsDouble timeStats[TimeTypeCard];
|
||||||
};
|
};
|
||||||
static TreeStats globalTreeStats;
|
static TreeStats globalTreeStats;
|
||||||
|
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
inline void
|
inline void
|
||||||
TreeStats::addDim (const treeType &type, const DimImg& leafCount, const DimImg& compCount) {
|
TreeStats::addDim (const TreeType &treeType, const DimImg& leafCount, const DimImg& compCount) {
|
||||||
leavesStats[type] (leafCount);
|
leavesStats[treeType] (leafCount);
|
||||||
compStats[type] (compCount);
|
compStats[treeType] (compCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
TreeStats::addTime (const statsIdxType &type, const double &duration) {
|
TreeStats::addTime (const TimeType &timeType, const double &duration) {
|
||||||
timeStats[type] (duration);
|
timeStats[timeType] (duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|||||||
@ -121,6 +121,8 @@ Option::parse (int argc, char** argv) {
|
|||||||
("use-the-force-luke", po::bool_switch (&useTheForceLuke), "display hidded options")
|
("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)")
|
("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")
|
("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)")
|
// ("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")
|
// ("dap", po::bool_switch (&options.dapFlag), "produce DAP rather than AP")
|
||||||
// ("use-all-orig", po::bool_switch (&options.useAllOrigFlag), "force use all original band")
|
// ("use-all-orig", po::bool_switch (&options.useAllOrigFlag), "force use all original band")
|
||||||
|
|||||||
@ -13,6 +13,6 @@ otb::triskele::arrayTree::tileItemName[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
otb::triskele::arrayTree::treeName[] = {
|
otb::triskele::arrayTree::treeTypeLabels[] = {
|
||||||
"min", "max", "tos"
|
"min", "max", "tos"
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using namespace otb::triskele;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
static string timeStatsLabels [statsIdxTypeCount] = {
|
static string timeTypeLabels [TimeTypeCard] = {
|
||||||
"build tree",
|
"build tree",
|
||||||
"area",
|
"area",
|
||||||
"average",
|
"average",
|
||||||
@ -51,10 +51,10 @@ TreeStats::printDim (ostream &out, const TreeStatsDim stats[], const string &msg
|
|||||||
<< setw (9) << left << "Mean" << "\t"
|
<< setw (9) << left << "Mean" << "\t"
|
||||||
<< setw (9) << left << "Min" << "\t"
|
<< setw (9) << left << "Min" << "\t"
|
||||||
<< setw (9) << left << "Max" << endl;
|
<< 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]))
|
if (!ba::count (stats[i]))
|
||||||
continue;
|
continue;
|
||||||
cout << setw (11) << right << treeName [i] << "\t"
|
cout << setw (11) << right << treeTypeLabels [i] << "\t"
|
||||||
<< setw (3) << ba::count (stats[i]) << "\t"
|
<< setw (3) << ba::count (stats[i]) << "\t"
|
||||||
<< setw (9) << DimImg (ba::mean (stats[i])) << "\t"
|
<< setw (9) << DimImg (ba::mean (stats[i])) << "\t"
|
||||||
<< setw (9) << ba::min (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 &
|
ostream &
|
||||||
TreeStats::printDim (ostream &out) {
|
TreeStats::printDim (ostream &out) {
|
||||||
bool empty = true;
|
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])))
|
if (!(empty = !ba::count (leavesStats[i])))
|
||||||
break;
|
break;
|
||||||
if (empty)
|
if (empty)
|
||||||
@ -79,7 +79,7 @@ TreeStats::printDim (ostream &out) {
|
|||||||
ostream &
|
ostream &
|
||||||
TreeStats::printTime (ostream &out) {
|
TreeStats::printTime (ostream &out) {
|
||||||
bool empty = true;
|
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])))
|
if (!(empty = !ba::count (timeStats[i])))
|
||||||
break;
|
break;
|
||||||
if (empty)
|
if (empty)
|
||||||
@ -91,10 +91,10 @@ TreeStats::printTime (ostream &out) {
|
|||||||
<< setw (15) << left << "Mean" << "\t"
|
<< setw (15) << left << "Mean" << "\t"
|
||||||
<< setw (15) << left << "Min" << "\t"
|
<< setw (15) << left << "Min" << "\t"
|
||||||
<< setw (15) << left << "Max" << endl;
|
<< 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]))
|
if (!ba::count (timeStats[i]))
|
||||||
continue;
|
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::sum (timeStats[i])) << "\t" << setw (3) << ba::count (timeStats[i]) << "\t"
|
||||||
<< ns2string (ba::mean (timeStats[i])) << "\t"
|
<< ns2string (ba::mean (timeStats[i])) << "\t"
|
||||||
<< ns2string (ba::min (timeStats[i])) << "\t"
|
<< ns2string (ba::min (timeStats[i])) << "\t"
|
||||||
|
|||||||
@ -61,6 +61,8 @@ void apGenerator (Option &option) {
|
|||||||
treeTypes.push_back (MAX);
|
treeTypes.push_back (MAX);
|
||||||
if (option.tosTreeFlag)
|
if (option.tosTreeFlag)
|
||||||
treeTypes.push_back (TOS);
|
treeTypes.push_back (TOS);
|
||||||
|
if (option.alphaTreeFlag)
|
||||||
|
treeTypes.push_back (ALPHA);
|
||||||
DimChanel treeTypesCard = treeTypes.size ();
|
DimChanel treeTypesCard = treeTypes.size ();
|
||||||
if (!treeTypesCard)
|
if (!treeTypesCard)
|
||||||
cerr << "*** no tree type ! => copy mode" << endl;
|
cerr << "*** no tree type ! => copy mode" << endl;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user