Merge remote-tracking branch 'origin/master' into python

This commit is contained in:
Florent Guiotte 2018-04-11 11:10:12 +02:00
commit 55013a04dd
41 changed files with 429 additions and 216 deletions

View File

@ -21,8 +21,8 @@ PRF_SRC = $(patsubst %, $(CPP_DIR)/%.cpp, $(PRF_PRG))
PRF_OUT = $(patsubst %, $(OUT_DIR)/%, $(PRF_PRG))
## FLAGS ###############################
DFLAGS = -O2 -DNDEBUG -DBOOST_DISABLE_ASSERTS -DNO_OTB # -DINTEL_TBB_THREAD
#DFLAGS = -g -DENABLE_LOG -DNO_OTB -DTHREAD_DISABLE -DENABLE_SMART_LOG
DFLAGS = -O2 -DNDEBUG -DNO_OTB -DINTEL_TBB_THREAD # -DBOOST_DISABLE_ASSERTS
#DFLAGS = -g -DENABLE_LOG -DNO_OTB # -DTHREAD_DISABLE -DENABLE_SMART_LOG
IFLAGS = $(DFLAGS) -MMD -I$(HPP_DIR) -I/usr/include/gdal
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 -ltbb
CC = g++
@ -48,7 +48,7 @@ testB: all
$(APG_OUT) data/10m.tif data/result.tif --min-tree --max-tree --tos-tree --alpha-tree -A data/areaThresholds.txt -S data/sdThresholds.txt -M data/moiThresholds.txt # --debug
perfA: all
$(PRF_OUT) MIN 8 20 1000000
$(PRF_OUT) MIN 4 20 1000000
init:
mkdir -p $(OUT_DIR) $(OBJ_DIR) $(LIB_DIR)

0
data/10m.tif Normal file → Executable file
View File

0
data/areaThresholds.txt Normal file → Executable file
View File

0
data/moiThresholds.txt Normal file → Executable file
View File

0
data/sdThresholds.txt Normal file → Executable file
View File

View File

@ -23,6 +23,7 @@ namespace otb {
Point topLeft = NullPoint;
Size size = NullSize;
Selected selectedBand;
size_t countingSortCeil = 2;
vector<DimImg> areaThresholds;
vector<double> sdThresholds, moiThresholds;
unsigned int coreCount = boost::thread::hardware_concurrency ();

View File

@ -30,7 +30,7 @@ namespace otb {
const Raster<PixelT> &raster;
const GraphWalker &graphWalker;
TreeType treeType;
bool countingFlag;
size_t countingSortCeil;
Leader leaders;
// transcient
@ -39,7 +39,7 @@ namespace otb {
WeightT *compWeights;
public:
inline ArrayTreeBuilder (const Raster<PixelT> &raster, const GraphWalker &graphWalker,
const TreeType &treeType, const bool &countingSort = true);
const TreeType &treeType, const size_t &countingSortCeil = 2);
inline ~ArrayTreeBuilder ();
inline void buildTree (Tree &tree, WeightAttributes<WeightT> &weightAttributes);

View File

@ -7,12 +7,12 @@ using namespace boost::chrono;
template<typename WeightT, typename PixelT>
inline
ArrayTreeBuilder<WeightT, PixelT>::ArrayTreeBuilder (const Raster<PixelT> &raster, const GraphWalker &graphWalker,
const TreeType &treeType, const bool &countingSort) :
const TreeType &treeType, const size_t &countingSortCeil) :
coreCount (boost::thread::hardware_concurrency ()),
raster (raster),
graphWalker (graphWalker),
treeType (treeType),
countingFlag (countingSort),
countingSortCeil (countingSortCeil),
compWeights (nullptr),
childCount (nullptr),
newCompId (nullptr)
@ -30,7 +30,7 @@ template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<WeightT> &weightAttributes) {
DEF_LOG ("ArrayTreeBuilder::buildTree", "size:" << graphWalker.vertexMaxCount ());
setTreeSize (tree, graphWalker.size);
setTreeSize (tree, graphWalker.getSize ());
weightAttributes.updateTranscient ();
if (!leafCount)
return;
@ -114,7 +114,7 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
vector<Rect> tiles;
vector<Rect> boundaries;
vector<bool> verticalBoundaries;
const Size &size (graphWalker.size);
const Size &size (graphWalker.getSize ());
graphWalker.setTiles (coreCount, Rect (NullPoint, size), tiles, boundaries, verticalBoundaries);
unsigned int tileCount = tiles.size ();
unsigned int boundCount = boundaries.size ();
@ -248,12 +248,12 @@ template<typename WeightFunct>
inline void
ArrayTreeBuilder<WeightT, PixelT>::buildParents (Edge<WeightT> *edges, const WeightFunct &weightFunct,
const Rect &tile, DimImg &topParent) {
SMART_DEF_LOG ("ArrayTreeBuilder::buildParents", " tile:" << tile << " topParent:" << topParent << " counting:" << countingFlag);
DimEdge edgeCount = (sizeof (WeightT) < 3 || countingFlag) ?
SMART_DEF_LOG ("ArrayTreeBuilder::buildParents", " tile:" << tile << " topParent:" << topParent << " counting:" << countingSortCeil);
DimEdge edgeCount = (sizeof (WeightT) <= countingSortCeil) ?
graphWalker.getCountingSortedEdges<WeightT, WeightFunct> (tile, Surface, edges, weightFunct) :
graphWalker.getSortedEdges (tile, Surface, edges, weightFunct);
const Size &size = graphWalker.size;
const Size &size = graphWalker.getSize ();
for (DimEdge edgeIdx = 0; edgeIdx < edgeCount; ++edgeIdx) {
Edge<WeightT> &curEdge = edges[edgeIdx];
DimImg pa = point2idx (size, curEdge.points[0]);

View File

@ -42,13 +42,16 @@ namespace otb {
/*! Construit Border, les valeurs de map dépendent de defaultVal */
inline Border (const Size &size, bool defaultVal);
inline Border (const Border &border, const Rect &tile);
inline ~Border ();
inline void reset (bool defaultVal);
inline const Size &getSize () const;
/*! Compte le nombre de pixels considérés comme de la bordure */
inline DimImg borderCount ();
private:
/*! Nombre de pixels dans l'image */
DimImg pixelsCount;
@ -62,6 +65,10 @@ namespace otb {
/*! Tableau "simplifié" des pixels */
vector<uint8_t> map;
bool defaultVal;
inline void createMap ();
friend inline ostream &operator << (ostream &out, const Border &border);
};

View File

@ -12,32 +12,40 @@ Border::getMapLength (DimImg pixelsCount) {
inline bool
Border::isBorder (DimImg idx) const {
return map.size () ? map[idx/8] & (1 << (idx%8)) : false;
BOOST_ASSERT (idx < pixelsCount);
return map.size () ? map[idx/8] & (1 << (idx%8)) : defaultVal;
}
inline bool
Border::isBorder (const Point &p) const {
return map.size () ? isBorder (pointToId (size, p)) : false;
BOOST_ASSERT (p.x < size.width && p.y < size.height);
return isBorder (point2idx (size, p));
}
inline void
Border::clearBorder (DimImg idx) {
if (!map.size ())
createMap ();
BOOST_ASSERT (idx < pixelsCount);
map[idx/8] &= ~(1 << (idx%8));
}
inline void
Border::clearBorder (const Point &p) {
clearBorder (pointToId (size, p));
clearBorder (point2idx (size, p));
}
inline void
Border::setBorder (DimImg idx) {
if (!map.size ())
createMap ();
BOOST_ASSERT (idx < pixelsCount);
map[idx/8] |= (1 << (idx%8));
}
inline void
Border::setBorder (const Point &p) {
setBorder (pointToId (size, p));
setBorder (point2idx (size, p));
}
inline
@ -45,29 +53,57 @@ Border::Border ()
: pixelsCount (0),
mapLength (0),
size (),
map () {
}
map (),
defaultVal (false) {
}
inline
Border::Border (const Size &size, bool defaultVal)
: pixelsCount (getPixelsCount (size)),
size (size),
mapLength (getMapLength (pixelsCount)),
size (size) {
reset (defaultVal);
map (),
defaultVal (defaultVal) {
}
inline
Border::Border (const Border &border, const Rect &tile)
: size (tile.width, tile.height),
pixelsCount (getPixelsCount (size)),
mapLength (getMapLength (pixelsCount)),
map (),
defaultVal (border.defaultVal) {
if (!border.map.size ())
return;
// XXX todo
// width >= 8 => for bytes
// width < 8 => for bits
BOOST_ASSERT (false);
}
inline
Border::~Border () {
}
inline void
Border::reset (bool defaultVal) {
this->defaultVal = defaultVal;
map.clear ();
}
inline void
Border::createMap () {
map.assign (mapLength, defaultVal ? 0xFF : 0);
if (!(mapLength && defaultVal))
return;
map[mapLength-1] &= 0xFF >> (8-(pixelsCount%8))%8;
}
inline const Size &
Border::getSize () const {
return size;
}
inline DimImg
Border::borderCount () {
DimImg result = 0;

View File

@ -29,26 +29,32 @@ namespace otb {
/** GraphWalker */
class GraphWalker {
public:
const Size size;
const Border &border;
const Connectivity connectivity;
inline const Size &getSize () const;
inline GraphWalker (const Border &border, const Connectivity &connectivity = Connectivity::C4);
inline GraphWalker (const Size &size, const Border &border, const Connectivity &connectivity = Connectivity::C4);
inline DimImg vertexMaxCount () const;
inline DimImg vertexMaxCount (const Size &tileSize) const;
static inline DimImg vertexMaxCount (const Size &tileSize);
inline DimEdge edgeMaxCount () const;
inline DimEdge edgeMaxCount (const Size &tileSize) const;
inline DimEdge edgeBoundaryMaxCount (const DimSideImg &side) const;
inline void setTiles (const unsigned int &coreCount, const Rect &tile,
vector<Rect> &tiles, vector<Rect> &boundaries, vector<bool> &verticalBoundaries) const;
inline void setTiles (const unsigned int &coreCount,
vector<Rect> &tiles, vector<Rect> &boundaries, vector<bool> &verticalBoundaries) const {
setTiles (coreCount, Rect (NullPoint, border.getSize ()), tiles, boundaries, verticalBoundaries);
}
static inline void setTiles (const unsigned int &coreCount, const Rect &rect,
vector<Rect> &tiles, vector<Rect> &boundaries, vector<bool> &verticalBoundaries);
inline void setMaxBounds (const vector<Rect> &tiles, vector<DimImg> &vertexMaxBounds, vector<DimImg> &edgesMaxBounds) const;
template<typename Funct>
inline DimImg forEachVertexIdx (const Funct &lambda /*lambda (idx)*/) const;
template<typename Funct>
DimImg forEachVertexPt (const Funct &lambda /*lambda (p)*/) const {
return forEachVertexIdx ([this, &lambda] (const Point &p) { lambda (point2idx (size, p)); });
const Size &size (border.getSize ());
return forEachVertexIdx ([&lambda, &size] (const Point &p) { lambda (point2idx (size, p)); });
}
template<typename Funct>
inline DimImg forEachVertexIdx (const Rect &rect, const Funct &lambda /*lambda (idx)*/) const;

View File

@ -1,31 +1,37 @@
#ifndef _OTB_TRISKELE_ARRAY_TREE_GRAPHWALKER_TPP
#define _OTB_TRISKELE_ARRAY_TREE_GRAPHWALKER_TPP
// ========================================
inline const Size &
GraphWalker::getSize () const {
return border.getSize ();
}
// ========================================
inline
GraphWalker::GraphWalker (const Size &size, const Border &border, const Connectivity &connectivity)
: size (size), border (border), connectivity (connectivity) {
DEF_LOG ("GraphWalker::GraphWalker", "size: " << size);
BOOST_ASSERT (size.width >= DimImg (0));
BOOST_ASSERT (size.height >= DimImg (0));
GraphWalker::GraphWalker (const Border &border, const Connectivity &connectivity)
: border (border), connectivity (connectivity) {
DEF_LOG ("GraphWalker::GraphWalker", "size: " << border.getSize ());
BOOST_ASSERT (border.getSize ().width >= DimImg (0));
BOOST_ASSERT (border.getSize ().height >= DimImg (0));
}
// ----------------------------------------
inline DimImg
GraphWalker::vertexMaxCount () const {
return vertexMaxCount (size);
return vertexMaxCount (border.getSize ());
}
// ----------------------------------------
inline DimImg
GraphWalker::vertexMaxCount (const Size &tileSize) const {
GraphWalker::vertexMaxCount (const Size &tileSize) {
return DimImg (tileSize.width)*DimImg (tileSize.height);
}
// ----------------------------------------
inline DimEdge
GraphWalker::edgeMaxCount () const {
return edgeMaxCount (size);
return edgeMaxCount (border.getSize ());
}
// ----------------------------------------
@ -64,20 +70,20 @@ GraphWalker::edgeBoundaryMaxCount (const DimSideImg &side) const {
// ========================================
inline void
GraphWalker::setTiles (const unsigned int &coreCount, const Rect &tile,
vector<Rect> &tiles, vector<Rect> &boundaries, vector<bool> &verticalBoundaries) const {
GraphWalker::setTiles (const unsigned int &coreCount, const Rect &rect,
vector<Rect> &tiles, vector<Rect> &boundaries, vector<bool> &verticalBoundaries) {
BOOST_ASSERT (coreCount);
DEF_LOG ("GraphWalker::setTiles", "coreCount:" << coreCount << " tile:" << tile);
if (coreCount < 2 || max (tile.width, tile.height) < 4 || min (tile.width, tile.height) < 3) {
LOG ("tile:" << tile);
tiles.push_back (tile);
DEF_LOG ("GraphWalker::setTiles", "coreCount:" << coreCount << " rect:" << rect);
if (coreCount < 2 || max (rect.width, rect.height) < 4 || min (rect.width, rect.height) < 3) {
LOG ("rect:" << rect);
tiles.push_back (rect);
return;
}
bool vertical = tile.width > tile.height;
bool vertical = rect.width > rect.height;
bool odd = coreCount & 0x1;
DimImg thin = (vertical ? tile.width : tile.height) / (odd ? coreCount : 2);
Rect tileA (tile);
Rect tileB (tile);
DimImg thin = (vertical ? rect.width : rect.height) / (odd ? coreCount : 2);
Rect tileA (rect);
Rect tileB (rect);
if (vertical) {
tileA.width = thin;
tileB.x += thin;
@ -121,6 +127,7 @@ GraphWalker::forEachVertexIdx (const Funct &lambda /*lambda (DimImg idx)*/) cons
template<typename Funct>
inline DimImg
GraphWalker::forEachVertexIdx (const Rect &rect, const Funct &lambda /*lambda (DimImg idx)*/) const {
const Size &size (border.getSize ());
DimImg vertexCount = 0;
DimSideImg const lastX = rect.x+rect.width;
DimSideImg const lastY = rect.y+rect.height;
@ -136,6 +143,7 @@ GraphWalker::forEachVertexIdx (const Rect &rect, const Funct &lambda /*lambda (D
template<typename Funct>
inline DimImg
GraphWalker::forEachVertexPt (const Rect &rect, const Funct &lambda /*lambda (Point p)*/) const {
const Size &size (border.getSize ());
DimImg vertexCount = 0;
DimSideImg const lastX = rect.x+rect.width;
DimSideImg const lastY = rect.y+rect.height;
@ -275,9 +283,9 @@ inline DimEdge
GraphWalker::getSortedEdges (const Rect &rect, TileItem tileItem, Edge<WeightT> *edges, const EdgeWeightFunction &ef /*ef.getWeight (p0, p1) ef.sort ()*/) const {
SMART_DEF_LOG ("GraphWalker::getSortedEdges", "");
DimEdge edgeCount = getEdges (rect, tileItem, edges, ef);
// SMART_LOG (endl << printEdges (edges, size, edgeCount));
// SMART_LOG (endl << printEdges (edges, border.getSize (), edgeCount));
ef.sort (edges, edgeCount);
SMART_LOG (endl << printEdges (edges, size, edgeCount))
SMART_LOG (endl << printEdges (edges, border.getSize (), edgeCount))
return edgeCount;
}
@ -308,10 +316,13 @@ GraphWalker::getCountingSortedEdges (const Rect &rect, TileItem tileItem, Edge<W
} else
indices[0] = 0;
// extract edges
#ifdef ENABLE_SMART_LOG
const Size &size (border.getSize ());
#endif
forEachEdgePt (rect, tileItem,
[
#ifdef ENABLE_SMART_LOG
this,
&size,
#endif
&ef, &edges, &indices] (Point const &a, Point const &b) {
WeightT weight = ef.getWeight (a, b);

View File

@ -22,7 +22,7 @@ namespace otb {
vector<DimImg> leaders;
public:
inline Leader ();
inline Leader (DimImg vertexCount = 0);
inline ~Leader ();
/*! Remet à 0 et redéfinit la taille des tableaux */
@ -38,6 +38,7 @@ namespace otb {
inline void link (DimImg a, const DimImg &r);
inline DimImg *getLeaders ();
inline vector<DimImg> &getLeadersVector ();
};
#include "Leader.tpp"

View File

@ -3,9 +3,9 @@
// ========================================
inline
Leader::Leader ()
: size (0),
leaders () {
Leader::Leader (DimImg vertexCount)
: size (vertexCount),
leaders (size, DimImg_MAX) {
}
inline
@ -67,6 +67,10 @@ Leader::getLeaders () {
return &leaders[0];
}
inline vector<DimImg> &
Leader::getLeadersVector () {
return leaders;
}
// ========================================
#endif // _OTB_TRISKELE_ARRAY_TREE_LEADER_TPP

View File

@ -5,6 +5,7 @@
#include <typeinfo>
#include "triskeleBase.hpp"
#include "IImage.hpp"
#include "triskeleArrayTreeBase.hpp"
namespace otb {
@ -14,13 +15,16 @@ namespace otb {
class GraphWalker;
/*! Structure définissant la base d'un poids entre les pixels */
template <typename PixelT> struct WeightBase {
template <typename PixelT, typename WeightT> struct WeightBase {
protected:
const PixelT *pixels;
const Size size;
Size size;
inline DimNodeId pointIdx (const Point &p) const;
PixelT halfPixel, maxPixel;
inline void reset (const PixelT *pixels, const Size &size);
public:
const PixelT *getPixels () const { return pixels; }
inline const Size &getSize () const;
inline const PixelT &getValue (const DimImg &idx) const;
inline const PixelT &getValue (const Point &p) const;
@ -28,15 +32,7 @@ namespace otb {
inline const PixelT &getMaxPixel () const;
inline const PixelT &getHalfPixel () const;
inline PixelT *allocAP (const DimNodeId &nodeCapacity) const;
inline WeightBase (const PixelT *pixels, const Size &size);
};
template <typename PixelT, typename WeightT> struct WeightBase2 : public WeightBase<PixelT> {
typedef WeightBase<PixelT> WB;
inline WeightBase2 (const PixelT *pixels, const Size &size);
static inline bool isWeightInf (const WeightT &a, const WeightT &b);
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
@ -49,15 +45,17 @@ namespace otb {
};
/*! Structure intégrant la façon dont est géré un poids pour un MinTree */
template <typename PixelT, typename WeightT> struct MinWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
template <typename PixelT, typename WeightT> struct MinWeight : public WeightBase<PixelT, WeightT> {
typedef WeightBase<PixelT, WeightT> WB;
inline bool getDecr () const;
static inline bool isWeightInf (const WeightT &a, const WeightT &b);
static inline bool isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b);
static inline void sort (Edge<WeightT> *edges, DimEdge count);
inline MinWeight ();
inline MinWeight (const PixelT *pixels, const Size &size);
inline MinWeight (const MinWeight &model, const PixelT *pixels, const Size &size);
inline WeightT getWeight (const DimImg &idx) const;
inline WeightT getWeight (const Point &a, const Point &b) const;
@ -65,10 +63,12 @@ namespace otb {
// ========================================
/*! Structure intégrant la façon dont est géré un poids pour un MaxTree */
template <typename PixelT, typename WeightT> struct MaxWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
template <typename PixelT, typename WeightT> struct MaxWeight : public WeightBase<PixelT, WeightT> {
typedef WeightBase<PixelT, WeightT> WB;
inline MaxWeight ();
inline MaxWeight (const PixelT *pixels, const Size &size);
inline MaxWeight (const MaxWeight &model, const PixelT *pixels, const Size &size);
inline WeightT getWeight (const DimImg &idx) const;
inline WeightT getWeight (const Point &a, const Point &b) const;
@ -76,10 +76,12 @@ namespace otb {
// ========================================
/*! Structure intégrant la façon dont est géré un poids pour un AlphaTree */
template <typename PixelT, typename WeightT> struct DiffWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
template <typename PixelT, typename WeightT> struct DiffWeight : public WeightBase<PixelT, WeightT> {
typedef WeightBase<PixelT, WeightT> WB;
inline DiffWeight ();
inline DiffWeight (const PixelT *pixels, const Size &size);
inline DiffWeight (const DiffWeight &model, const PixelT *pixels, const Size &size);
inline WeightT getWeight (const DimImg &idx) const;
inline WeightT getWeight (const Point &a, const Point &b) const;
@ -87,8 +89,8 @@ namespace otb {
// ========================================
/*! Structure intégrant la façon dont est géré un poids pour un TreeOfShape */
template <typename PixelT, typename WeightT> struct MedianWeight : public WeightBase2<PixelT, WeightT> {
typedef WeightBase2<PixelT, WeightT> WB;
template <typename PixelT, typename WeightT> struct MedianWeight : public WeightBase<PixelT, WeightT> {
typedef WeightBase<PixelT, WeightT> WB;
protected:
PixelT median, thresholdPixel;
WeightT thresholdWeight;
@ -106,7 +108,9 @@ namespace otb {
inline WeightT value2weight (const PixelT &val) const;
inline PixelT weight2value (const WeightT &weight) const;
inline MedianWeight ();
inline MedianWeight (const PixelT *pixels, const GraphWalker &graphWalker);
inline MedianWeight (const MedianWeight &model, const PixelT *pixels, const Size &size);
inline WeightT getWeight (const DimImg &idx) const;
inline WeightT getWeight (const Point &a, const Point &b) const;

View File

@ -2,100 +2,97 @@
#define _OTB_TRISKELE_ARRAY_TREE_WEIGHT_TPP
// ========================================
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline DimNodeId
WeightBase<PixelT>::pointIdx (const Point &p) const {
WeightBase<PixelT, WeightT>::pointIdx (const Point &p) const {
return point2idx (size, p);
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline const Size &
WeightBase<PixelT>::getSize () const {
WeightBase<PixelT, WeightT>::getSize () const {
return size;
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline const PixelT &
WeightBase<PixelT>::getValue (const DimImg &idx) const {
WeightBase<PixelT, WeightT>::getValue (const DimImg &idx) const {
return pixels[idx];
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline const PixelT &
WeightBase<PixelT>::getValue (const Point &p) const {
WeightBase<PixelT, WeightT>::getValue (const Point &p) const {
return getValue (pointIdx (p));
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline bool
WeightBase<PixelT>::getDecr () const {
WeightBase<PixelT, WeightT>::getDecr () const {
return false;
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline const PixelT &
WeightBase<PixelT>::getMaxPixel () const {
WeightBase<PixelT, WeightT>::getMaxPixel () const {
return maxPixel;
}
template <typename PixelT>
template <typename PixelT, typename WeightT>
inline const PixelT &
WeightBase<PixelT>::getHalfPixel () const {
WeightBase<PixelT, WeightT>::getHalfPixel () const {
return halfPixel;
}
template <typename PixelT>
inline PixelT *
WeightBase<PixelT>::allocAP (const DimNodeId &nodeCapacity) const {
return new PixelT [nodeCapacity];
}
template <typename PixelT>
inline
WeightBase<PixelT>::WeightBase (const PixelT *pixels, const Size &size)
: pixels (pixels),
size (size) {
template <typename PixelT, typename WeightT>
inline void
WeightBase<PixelT, WeightT>::reset (const PixelT *pixels, const Size &size) {
this->pixels = pixels;
this->size = size;
maxPixel = std::numeric_limits<PixelT>::max ();
// only if unsigned
halfPixel = maxPixel / 2;
if (typeid (PixelT) != typeid (float))
halfPixel++;
}
template <typename PixelT, typename WeightT>
inline
WeightBase<PixelT, WeightT>::WeightBase (const PixelT *pixels, const Size &size)
: pixels (nullptr),
size (NullSize) {
reset (pixels, size);
}
// ========================================
template <typename PixelT, typename WeightT>
inline
WeightBase2<PixelT, WeightT>::WeightBase2 (const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline bool
WeightBase2<PixelT, WeightT>::isWeightInf (const WeightT &a, const WeightT &b) {
WeightBase<PixelT, WeightT>::isWeightInf (const WeightT &a, const WeightT &b) {
return a < b;
}
template <typename PixelT, typename WeightT>
inline bool
WeightBase2<PixelT, WeightT>::isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b) {
WeightBase<PixelT, WeightT>::isEdgeInf (const Edge<WeightT> &a, const Edge<WeightT> &b) {
return isWeightInf (a.weight, b.weight);
}
template <typename PixelT, typename WeightT>
inline void
WeightBase2<PixelT, WeightT>::sort (Edge<WeightT> *edges, DimEdge count) {
WeightBase<PixelT, WeightT>::sort (Edge<WeightT> *edges, DimEdge count) {
std::sort (edges, edges+count, isEdgeInf);
}
template <typename PixelT, typename WeightT>
inline void
WeightBase2<PixelT, WeightT>::copyPixelsBound (PixelT *leafAPTree, const DimImg &minVal, const DimImg &maxVal) const {
WeightBase<PixelT, WeightT>::copyPixelsBound (PixelT *leafAPTree, const DimImg &minVal, const DimImg &maxVal) const {
for (DimImg i = minVal; i < maxVal; ++i)
leafAPTree[i] = WB::pixels [i];
leafAPTree[i] = pixels [i];
}
template <typename PixelT, typename WeightT>
inline void
WeightBase2<PixelT, WeightT>::weight2valueBound (PixelT *compAPTree, const WeightT *compWeights,
const DimImg &minVal, const DimImg &maxVal) const {
WeightBase<PixelT, WeightT>::weight2valueBound (PixelT *compAPTree, const WeightT *compWeights,
const DimImg &minVal, const DimImg &maxVal) const {
//memcpy (compAPTree+minVal, compWeights+minVal, maxVal-minVal);
for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx)
compAPTree[compIdx] = compWeights[compIdx];
@ -126,12 +123,24 @@ MinWeight<PixelT, WeightT>::sort (Edge<WeightT> *edges, DimEdge count) {
std::sort (edges, edges+count, isEdgeInf);
}
template <typename PixelT, typename WeightT>
inline
MinWeight<PixelT, WeightT>::MinWeight ()
: WB (nullptr, NullSize) {
}
template <typename PixelT, typename WeightT>
inline
MinWeight<PixelT, WeightT>::MinWeight (const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline
MinWeight<PixelT, WeightT>::MinWeight (const MinWeight &model, const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline WeightT
MinWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
@ -146,12 +155,24 @@ MinWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
}
// ========================================
template <typename PixelT, typename WeightT>
inline
MaxWeight<PixelT, WeightT>::MaxWeight ()
: WB (nullptr, NullSize) {
}
template <typename PixelT, typename WeightT>
inline
MaxWeight<PixelT, WeightT>::MaxWeight (const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline
MaxWeight<PixelT, WeightT>::MaxWeight (const MaxWeight &model, const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline WeightT
MaxWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
@ -166,12 +187,24 @@ MaxWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const {
}
// ========================================
template <typename PixelT, typename WeightT>
inline
DiffWeight<PixelT, WeightT>::DiffWeight ()
: WB (nullptr, NullSize) {
}
template <typename PixelT, typename WeightT>
inline
DiffWeight<PixelT, WeightT>::DiffWeight (const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline
DiffWeight<PixelT, WeightT>::DiffWeight (const DiffWeight &model, const PixelT *pixels, const Size &size)
: WB (pixels, size) {
}
template <typename PixelT, typename WeightT>
inline WeightT
DiffWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
@ -254,6 +287,34 @@ MedianWeight<PixelT, WeightT>::weight2value (const WeightT &weight) const {
return int (weight) % 2 ? median - weight/2 : median + weight/2;
}
// ========================================
template <typename PixelT, typename WeightT>
inline
MedianWeight<PixelT, WeightT>::MedianWeight ()
: WB (nullptr, NullSize),
median (0),
thresholdPixel (0),
thresholdWeight (0) {
}
template <typename PixelT, typename WeightT>
inline
MedianWeight<PixelT, WeightT>::MedianWeight (const PixelT *pixels, const GraphWalker &graphWalker)
: WB (pixels, graphWalker.getSize ()) {
median = graphWalker.getMedian<WeightT> (*this);
thresholdPixel = median < WB::halfPixel ? median * 2 : WB::maxPixel - (WB::maxPixel-median) * 2;
thresholdWeight = median < WB::halfPixel ? median * 2 : (WB::maxPixel-median) * 2;
}
template <typename PixelT, typename WeightT>
inline
MedianWeight<PixelT, WeightT>::MedianWeight (const MedianWeight &model, const PixelT *pixels, const Size &size)
: WB (pixels, size),
median (model.median),
thresholdPixel (model.thresholdPixel),
thresholdWeight (model.thresholdWeight) {
}
template <typename PixelT, typename WeightT>
inline WeightT
MedianWeight<PixelT, WeightT>::getWeight (const DimImg &idx) const {
@ -270,21 +331,11 @@ MedianWeight<PixelT, WeightT>::getWeight (const Point &a, const Point &b) const
template <typename PixelT, typename WeightT>
inline void
MedianWeight<PixelT, WeightT>::weight2valueBound (PixelT *compAPTree, const WeightT *compWeights,
const DimImg &minVal, const DimImg &maxVal) const {
const DimImg &minVal, const DimImg &maxVal) const {
for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx)
compAPTree[compIdx] = weight2value (compWeights[compIdx]);
}
// ========================================
template <typename PixelT, typename WeightT>
inline
MedianWeight<PixelT, WeightT>::MedianWeight (const PixelT *pixels, const GraphWalker &graphWalker)
: WB (pixels, graphWalker.size) {
median = graphWalker.getMedian<WeightT> (*this);
thresholdPixel = median < WB::halfPixel ? median * 2 : WB::maxPixel - (WB::maxPixel-median) * 2;
thresholdWeight = median < WB::halfPixel ? median * 2 : (WB::maxPixel-median) * 2;
}
// ========================================
#endif // _OTB_TRISKELE_ARRAY_TREE_WEIGHT_TPP

View File

@ -55,6 +55,7 @@ AttributeProfiles<PixelT>::print (ostream &out) const {
const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height);
out << "AP" << endl
<< printMap (&values[0], doubleSize, tree.getNodeCount ()) << endl << endl;
return out;
}
#endif // _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP

View File

@ -17,7 +17,7 @@ namespace otb {
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<DimImg> &thresholds) const;
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "area"); }
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "area"); return out; }
protected:
inline void compute ();
};

View File

@ -16,7 +16,7 @@ namespace otb {
template<typename PixelT>
inline AverageAttributes (const Tree &tree, const Raster<PixelT> &raster, const AreaAttributes &areaAttributes);
inline ~AverageAttributes ();
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "average"); }
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "average"); return out; }
protected:
template<typename PixelT>
inline void compute (const Raster<PixelT> &raster, const AreaAttributes &areaAttributes);

View File

@ -13,7 +13,7 @@ namespace otb {
public:
inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
inline ~MoIAttributes ();
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "moi"); }
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "moi"); return out; }
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,

View File

@ -15,7 +15,7 @@ namespace otb {
public:
inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
inline ~SDAttributes ();
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "sd"); }
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "sd"); return out; }
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,

View File

@ -16,7 +16,7 @@ namespace otb {
inline void setWeightBounds (Tree &tree);
virtual inline ostream &print (ostream &out) const { CompAttribute<WeightT>::print (out, "weight"); }
virtual inline ostream &print (ostream &out) const { CompAttribute<WeightT>::print (out, "weight"); return out; }
};
#include "WeightAttributes.tpp"

View File

@ -14,7 +14,7 @@ namespace otb {
struct AverageXY {
double x, y;
inline AverageXY () : x(0), y(0) {}
friend ostream &operator << (ostream& out, const AverageXY &xy) { return out << "(" << xy.x << ", " << xy.y << ")"; }
friend ostream &operator << (ostream& out, const AverageXY &xy) { return out << "(" << xy.x << ", " << xy.y << ")"; return out; }
operator DimImg () const { return (DimImg) (x*y); }
};
@ -22,7 +22,7 @@ namespace otb {
public:
inline XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
inline ~XYAttributes ();
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "xy"); }
virtual inline ostream &print (ostream &out) const { CompAttribute::print (out, "xy"); return out; }
protected:
inline void compute (const AreaAttributes &areaAttributes);
};

View File

@ -22,7 +22,7 @@ namespace otb {
inline AttrT *getValues ();
inline AttrT getMaxValue () const;
virtual inline ostream &print (ostream &out) const { print (out, ""); }
virtual inline ostream &print (ostream &out) const { print (out, ""); return out; }
protected:
const Tree &tree;

View File

@ -52,7 +52,7 @@ inline ostream &
CompAttribute<AttrT>::print (ostream &out, const string &msg) const {
cout << "values: " << msg << endl;
const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height);
cout << printMap (&values[0], doubleSize, tree.getCompCount ()) << endl << endl;
return cout << printMap (&values[0], doubleSize, tree.getCompCount ()) << endl << endl;
}
template<typename AttrT>

View File

@ -24,11 +24,13 @@ namespace triskele {
inline const Size &getSize () const;
inline const PixelT *getPixels () const;
inline PixelT *getPixels ();
inline vector<PixelT> &getPixelsVector ();
inline DimNodeId pointIdx (const Point &p) const;
inline PixelT getValue (const DimImg &idx) const;
inline PixelT getValue (const Point &point) const;
inline Raster (const Size &size = NullSize);
inline Raster (const Raster &raster, const Rect &tile);
inline ~Raster ();
};

View File

@ -30,6 +30,12 @@ Raster<PixelT>::getPixels () {
return &pixels[0];
}
template<typename PixelT>
inline vector<PixelT> &
Raster<PixelT>::getPixelsVector () {
return pixels;
}
template<typename PixelT>
inline DimNodeId
Raster<PixelT>::pointIdx (const Point &p) const {
@ -57,6 +63,14 @@ Raster<PixelT>::Raster (const Size &size)
setSize (size);
}
template<typename PixelT>
inline
Raster<PixelT>::Raster (const Raster &raster, const Rect &tile)
: size (tile.width, tile.height),
pixels () {
tile.cpToTile (raster.size, &raster.pixels[0], pixels);
}
template<typename PixelT>
inline
Raster<PixelT>::~Raster () {

View File

@ -72,7 +72,7 @@ namespace otb {
void resize (const DimSideImg &width, const DimSideImg &height);
// Setter for nodeCount and size
inline void setNodeCount (const DimImg &newNodeCount);
inline void setNodeCount (const DimNodeId &newNodeCount);
inline void setSize (const Size &newSize);
inline unsigned int getCoreCount () const;

View File

@ -18,13 +18,14 @@ namespace otb {
// Used to set the attributes below with the tree
inline void setTreeSize (Tree &tree, const Size &size);
inline void getTranscient (Tree &tree);
inline DimNodeId getCompCount () const;
inline DimImg getCompCount () const;
inline void setNodeCount (Tree &tree, DimNodeId nodeCount);
// Attributes corresponding to the tree, used to make the construction easier
DimImg leafCount, nodeCount;
DimImg leafCount;
DimNodeId nodeCount;
/*! Pointers on the parents of each leafs / nodes */
DimNodeId *leafParents, *compParents;
DimImg *leafParents, *compParents;
/*! Pointers on the children and count how many children a parents have */
DimNodeId *children, *childrenStart;

View File

@ -35,7 +35,7 @@ TreeBuilder::getTranscient (Tree &tree) {
childrenStart = &tree.childrenStart[0];
}
inline DimNodeId
inline DimImg
TreeBuilder::getCompCount () const {
return nodeCount-leafCount;
}

View File

@ -32,7 +32,10 @@ namespace otb {
enum TimeType {
buildTreeStats,
buildSetupStats,
buildToTilesStats,
buildEdgesStats,
buildParentsStats,
buildFromTilesStats,
buildMergeStats,
buildIndexStats,
buildCompressStats,

View File

@ -3,10 +3,13 @@
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdint>
#include "triskeleDebug.hpp"
#define DimImg_MAX UINT32_MAX
namespace triskele {
@ -28,44 +31,55 @@ namespace triskele {
/*! Compte le nombre de bits utilisés pour chaque nombre : bitCount[nombre] = nombre de bits*/
extern int bitCount[];
struct Point {
DimSideImg x, y;
inline Point ();
inline Point (const DimSideImg &abs, const DimSideImg &ord);
};
inline bool operator== (const Point &p1, const Point &p2);
inline ostream &operator << (ostream &out, const Point &p);
extern Point NullPoint;
struct Size {
DimSideImg width, height;
inline Size ();
inline Size (const Size &size);
inline Size (const DimSideImg &w, const DimSideImg &h);
};
inline bool operator== (const Size &s1, const Size &s2);
inline ostream &operator << (ostream &out, const Size &s);
extern Size NullSize;
inline DimImg pointToId (const Size &size, const Point &p);
inline Point idToPoint (const Size &size, const DimImg &id);
struct Point {
DimSideImg x, y;
inline Point ();
inline Point (const DimSideImg &abs, const DimSideImg &ord);
inline Point (const Size &size, const DimImg &idx);
};
inline bool operator== (const Point &p1, const Point &p2);
inline ostream &operator << (ostream &out, const Point &p);
extern Point NullPoint;
/*! Convertit un point d'un tableau (on peut imaginer une image à 2 dimension) en un index */
inline DimImg point2idx (const Size &size, const Point &p);
inline DimImg point2idx (const Size &size, const Point &tileOrig, const Point &p);
inline DimImg idxTile2idxRect (const Size &tileSize, const DimImg &tileIdx, const Size &rectSize, const DimImg tileOrig);
struct Rect {
DimSideImg x, y, width, height;
inline Rect ();
inline Rect (const Rect &rect);
inline Rect (const Point &orig, const Size &size);
inline Rect (const DimSideImg &abs, const DimSideImg &ord, const DimSideImg &w, const DimSideImg &h);
inline DimImg relIdx (const Point &absPos) const;
inline DimImg absIdx (const DimImg &relIdx, const Size &rectSize) const;
template<typename T>
inline void cpToTile (const Size &size, const T *src, vector<T> &dst) const;
template<typename T>
inline void cpFromTile (const Size &size, const vector<T> &src, T *dst) const;
template<typename T>
inline void cpFromTileMove (const Size &size, const vector<T> &src, T *dst, const T &move) const;
};
inline bool operator== (const Rect &r1, const Rect &r2);
inline ostream &operator << (ostream &out, const Rect &r);
extern Rect NullRect;
/*! Convertit un point d'un tableau (on peut imaginer une image à 2 dimension) en un index */
inline DimImg point2idx (const Size &size, const Point &p);
/*! Convertit un index d'un tableau (on peut imaginer une image à 2 dimension) en point correspondant à des coordonnées */
inline Point idx2point (const Size &size, const DimImg &idx);
static const DimSideImg printMapMaxSide = 25;
/*! Affiche le contenu d'un tableau en spécifiant sa taille */

View File

@ -1,35 +1,18 @@
#ifndef _OTB_TRISKELE_BASE_TPP
#define _OTB_TRISKELE_BASE_TPP
inline
Point::Point ()
: x (0),
y (0) {
}
inline
Point::Point (const DimSideImg &abs, const DimSideImg &ord)
: x (abs),
y (ord) {
}
inline bool
operator== (const Point &p1, const Point &p2) {
return p1.x == p2.x && p1.y == p2.y;
}
inline ostream &
operator << (ostream &out, const Point &p) {
return out << "(" << p.x << "," << p.y << ")";
}
inline
Size::Size ()
: width (0),
height (0) {
}
inline
Size::Size (const Size &size)
: width (size.width),
height (size.height) {
}
inline
Size::Size (const DimSideImg &w, const DimSideImg &h)
: width (w),
@ -46,14 +29,36 @@ operator << (ostream &out, const Size &s) {
return out << "[" << s.width << "," << s.height << "]";
}
inline DimImg
pointToId (const Size &size, const Point &p) {
return (DimImg)p.x + (DimImg)p.y * size.width;
inline
Point::Point ()
: x (0),
y (0) {
}
inline Point
idToPoint (const Size &size, const DimImg &id) {
return Point(id % size.width, id / size.width);
inline
Point::Point (const DimSideImg &abs, const DimSideImg &ord)
: x (abs),
y (ord) {
}
inline
Point::Point (const Size &size, const DimImg &idx)
: x (idx % size.width),
y (idx / size.width) {
}
inline bool
operator== (const Point &p1, const Point &p2) {
return p1.x == p2.x && p1.y == p2.y;
}
inline ostream &
operator << (ostream &out, const Point &p) {
return out << "(" << p.x << "," << p.y << ")";
}
inline DimImg point2idx (const Size &size, const Point &p) {
return DimImg (p.x) + DimImg (p.y)*DimImg (size.width);
}
inline
@ -88,6 +93,60 @@ Rect::Rect (const DimSideImg &abs, const DimSideImg &ord, const DimSideImg &w, c
height (h) {
}
inline DimImg
Rect::relIdx (const Point &p) const {
return DimImg (p.x-x) + DimImg (p.y-y)*DimImg (width);
}
inline DimImg
Rect::absIdx (const DimImg &relIdx, const Size &rectSize) const {
return (relIdx % width)+x + ((relIdx / width)+y)*rectSize.width;
}
template<typename T>
inline void
Rect::cpToTile (const Size &size, const T* src, vector<T> &dst) const {
// XXX no border
//SMART_DEF_LOG ("Rect::cpToTile", "rectSize:" << size);
const DimImg maxCount = width*height;
dst.resize (maxCount);
for (DimImg idx = 0; idx < maxCount; ++idx) {
dst [idx] = src [absIdx (idx, size)];
//SMART_LOG ("idx:" << idx << " abs:" << absIdx (idx, size));
}
// SMART_LOG ("tile:"<< *this << " src/dst:" << endl
// << printMap (src, size, 0) << endl
// << printMap (&dst[0], Size (width, height), 0));
}
template<typename T>
inline void
Rect::cpFromTile (const Size &size, const vector<T> &src, T *dst) const {
// XXX no border
const DimImg maxCount = width*height;
//SMART_DEF_LOG ("Rect::cpFromTile", "rectSize:" << size);
for (DimImg idx = 0; idx < maxCount; ++idx) {
dst [absIdx (idx, size)] = src [idx];
//SMART_LOG ("idx:" << idx << " abs:" << absIdx (idx, size));
}
// SMART_LOG ("tile:"<< *this << " src/dst:" << endl
// << printMap (&src[0], Size (width, height), 0) << endl
// << printMap (dst, size, 0));
}
template<typename T>
inline void
Rect::cpFromTileMove (const Size &size, const vector<T> &src, T *dst, const T &move) const {
// XXX no border
const DimImg maxCount = width*height;
DEF_LOG ("Rect::cpFromTileTrans", "rectSize:" << size << " move:" << move);
for (DimImg idx = 0; idx < maxCount; ++idx) {
dst [absIdx (idx, size)] = src [idx] + move;
//LOG ("idx:" << idx << " abs:" << absIdx (idx, size));
}
SMART_LOG ("tile:"<< *this << " src/dst:" << endl
<< printMap (&src[0], Size (width, height), 0) << endl
<< printMap (dst, size, 0));
}
inline bool
operator== (const Rect &r1, const Rect &r2) {
return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width && r1.height == r2.height;
@ -98,15 +157,6 @@ operator << (ostream &out, const Rect &r) {
return out << "[" << r.x << "," << r.y << " " << r.width << "x" << r.height << "]";
}
inline DimImg point2idx (const Size &size, const Point &p) {
return DimImg (p.x) + DimImg (p.y)*DimImg (size.width);
}
inline Point
idx2point (const Size &size, const DimImg &idx) {
return Point (idx % size.width, idx / size.width);
}
// ========================================
template <typename T>
inline

View File

@ -60,7 +60,6 @@ dealThread (const DimImg &maxId, unsigned int coreCount, const FunctThreadMinMax
}
std::vector<DimImg> maxIds = getDealThreadBounds (maxId, coreCount);
boost::thread tasks [coreCount];
#ifdef THREAD_DISABLE
for (unsigned int idCopyValInThread = 0; idCopyValInThread < coreCount; ++idCopyValInThread) {
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
@ -72,10 +71,11 @@ dealThread (const DimImg &maxId, unsigned int coreCount, const FunctThreadMinMax
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
});
#else /* BOOST thread */
boost::thread tasks [coreCount];
for (unsigned int idCopyValInThread = 0; idCopyValInThread < coreCount; ++idCopyValInThread) {
tasks[idCopyValInThread] = boost::thread ([/*no ref!!!*/idCopyValInThread, &maxIds, &functThreadMinMax] () {
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
});
tasks.push_back (boost::thread ([/*no ref!!!*/idCopyValInThread, &maxIds, &functThreadMinMax] () {
functThreadMinMax (idCopyValInThread, maxIds[idCopyValInThread], maxIds[idCopyValInThread+1]);
}));
}
for (unsigned int i = 0; i < coreCount; ++i)
tasks[i].join ();

View File

@ -18,7 +18,7 @@
#endif
#ifndef SMART_LOG_EXPR
#define SMART_LOG_EXPR(expr) {if (triskele::debug) expr; }
#define SMART_LOG_EXPR(expr) {if (triskele::debug) {expr;} }
#endif
#else

View File

@ -1,4 +1,4 @@
#define LAST_VERSION "2018-03-07 (Debian Stretch)"
#define LAST_VERSION "2018-03-29 (Debian Stretch)"
#include <iostream>
@ -123,6 +123,10 @@ Option::parse (int argc, char** argv) {
("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")
("counting-sort", po::value<size_t> (&countingSortCeil),
string ("force counting sort under ceil (default: "+
boost::lexical_cast<std::string> (countingSortCeil)+") (n.b. value in [0..2^16] => 300MB!)").c_str ())
// ("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")
@ -198,18 +202,18 @@ Option::parse (int argc, char** argv) {
selectedBand.toSet ();
Size orgSize = inputImage.getSize ();
if (width < 0 || width > orgSize.width)
width = left <= 0 ? orgSize.width : min (1L, orgSize.width-left);
if (height < 0 || height > orgSize.height)
height = top <= 0 ? orgSize.height : min (1L, orgSize.height-top);
if (width < 0 || width > (long) orgSize.width)
width = left <= 0 ? (long) orgSize.width : min (1L, (long) orgSize.width-left);
if (height < 0 || height > (long) orgSize.height)
height = top <= 0 ? (long) orgSize.height : min (1L, (long) orgSize.height-top);
if (left < 0)
left = (orgSize.width - width)/2;
left = ((long) orgSize.width - width)/2;
if (top < 0)
top = (orgSize.height - height)/2;
if (left > orgSize.width - width)
left = orgSize.width - width;
if (top > orgSize.height - height)
top = orgSize.height - height;
top = ((long) orgSize.height - height)/2;
if (left > (long) orgSize.width - width)
left = (long) orgSize.width - width;
if (top > (long) orgSize.height - height)
top = (long) orgSize.height - height;
topLeft = Point ((DimSideImg) left, (DimSideImg) top);
size = Size ((DimSideImg) width, (DimSideImg) height);

View File

@ -71,7 +71,7 @@ main (int argc, char **argv, char **envp) {
const size_t w = card/h;
Size size (w, h);
Border border (size, false);
GraphWalker graphWalker (size, border);
GraphWalker graphWalker (border);
int leafCount = graphWalker.vertexMaxCount ();
Raster<PixelT> raster (size);

View File

@ -211,7 +211,7 @@ void test () {
//Size size (18, 12);
Size size (12, 8);
Border border (size, false);
GraphWalker graphWalker (size, border);
GraphWalker graphWalker (border);
int leafCount = graphWalker.vertexMaxCount ();
// ====================

View File

@ -172,7 +172,7 @@ Tree::compareTo (const Tree &tree, bool testChildren) const {
void
Tree::checkSpare () const {
Border border; // default = no border
GraphWalker graphWalker (size, border);
GraphWalker graphWalker (border);
vector<Rect> tiles;
vector<Rect> boundaries;
vector<bool> verticalBoundaries;

View File

@ -10,12 +10,15 @@ using namespace std;
// ========================================
static string timeTypeLabels [TimeTypeCard] = {
"build tree",
"build setup ",
"build parents ",
"build merge ",
"build index ",
"build compress ",
"build children ",
" setup ",
" to tiles ",
" sort edges ",
" parents ",
" from tiles ",
" merge ",
" index ",
" compress ",
" children ",
"set AP",
"area",
"average",

View File

@ -66,8 +66,8 @@ void apGenerator (Option &option) {
if (!treeTypesCard)
cerr << "*** no tree type ! => copy mode" << endl;
Border border; // default = no border
GraphWalker graphWalker (option.size, border);
Border border (option.size, false); // default = no border
GraphWalker graphWalker (border);
DimImg leafCount = graphWalker.vertexMaxCount ();
DimChanel maxThresholds = max (max (option.areaThresholds.size (), option.sdThresholds.size ()), option.moiThresholds.size ());
vector <vector <PixelT> > allBands (maxThresholds, vector<PixelT> (leafCount, 0));
@ -83,7 +83,7 @@ void apGenerator (Option &option) {
writeBand (option, raster.getPixels (), chanel++);
for (TreeType treeType : treeTypes) {
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, treeType);
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, treeType, option.countingSortCeil);
Tree tree (option.coreCount);
WeightAttributes<PixelT> weightAttributes (tree);
atb.buildTree (tree, weightAttributes);