Gestion de no-data (bordure et connectivité
This commit is contained in:
parent
7499b5b827
commit
29b9443206
@ -25,10 +25,11 @@ PRF_OUT = $(patsubst %, $(OUT_DIR)/%, $(PRF_PRG))
|
||||
DFLAGS = -O2 -DNDEBUG -DNO_OTB -DINTEL_TBB_THREAD -DBOOST_DISABLE_ASSERTS
|
||||
# fast but control
|
||||
#DFLAGS = -O2 -DNDEBUG -DNO_OTB -DINTEL_TBB_THREAD
|
||||
# debut multi-threaded
|
||||
# debug multi-threaded
|
||||
#DFLAGS = -g -DENABLE_LOG -DNO_OTB
|
||||
# debut one thread
|
||||
# debug one thread
|
||||
#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++
|
||||
@ -54,7 +55,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 4 20 1000000
|
||||
$(PRF_OUT) MIN 32 20 1000000
|
||||
|
||||
init:
|
||||
mkdir -p $(OUT_DIR) $(OBJ_DIR) $(LIB_DIR)
|
||||
|
@ -19,6 +19,9 @@ Triskele suit partiellement le [[https://nvie.com/posts/a-successful-git-branchi
|
||||
|
||||
** Commandes utiles
|
||||
|
||||
- récupération du git
|
||||
$ git clone git://git.renater.fr/triskele.git
|
||||
|
||||
- Se déplacer sur une branche
|
||||
$ git checkout nomDeBranche
|
||||
|
||||
|
@ -6,12 +6,14 @@
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "triskeleBase.hpp"
|
||||
#include "ArrayTree/GraphWalker.hpp"
|
||||
#include "IImage.hpp"
|
||||
#include "Appli/Selected.hpp"
|
||||
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
using namespace ::triskele;
|
||||
using namespace otb::triskele::arrayTree;
|
||||
|
||||
// ========================================
|
||||
|
||||
@ -29,7 +31,8 @@ namespace otb {
|
||||
unsigned int coreCount = boost::thread::hardware_concurrency ();
|
||||
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false, alphaTreeFlag = false;
|
||||
bool averageFlag = false;
|
||||
bool oneBand = false;
|
||||
bool border = false, oneBand = false;
|
||||
Connectivity connectivity = Connectivity::C4;
|
||||
|
||||
Option ();
|
||||
Option (int argc, char** argv);
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
|
||||
/*! Fonction monotonne strictement croissante. */
|
||||
class AreaAttributes : public CompAttribute<DimImg> {
|
||||
public:
|
||||
inline AreaAttributes (const Tree &tree);
|
||||
|
@ -11,6 +11,7 @@
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
|
||||
/*! Fonction non monotonne. */
|
||||
class AverageAttributes : public CompAttribute<double> {
|
||||
public:
|
||||
template<typename PixelT>
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
|
||||
/*! Fonction monotonne strictement croissante. */
|
||||
class MoIAttributes : public CompAttribute<double> {
|
||||
public:
|
||||
inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
|
||||
|
@ -11,6 +11,7 @@
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
|
||||
/*! Fonction non monotonne, globalement croissante. */
|
||||
class SDAttributes : public CompAttribute<double> {
|
||||
public:
|
||||
inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace otb {
|
||||
namespace triskele {
|
||||
|
||||
/** Attribute */
|
||||
/*! Fonction monotonne strict croissante ou décroissante en fonction de la fonction de poid. */
|
||||
template<typename WeightT>
|
||||
class WeightAttributes : public CompAttribute<WeightT> {
|
||||
public:
|
||||
|
@ -11,6 +11,7 @@ namespace otb {
|
||||
namespace triskele {
|
||||
using namespace ::triskele;
|
||||
|
||||
/*! Fonction non monotonne. */
|
||||
struct AverageXY {
|
||||
double x, y;
|
||||
inline AverageXY () : x(0), y(0) {}
|
||||
|
@ -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
|
||||
@ -52,15 +52,15 @@
|
||||
#else
|
||||
|
||||
#ifndef DEF_LOG
|
||||
#define DEF_LOG(name, expr) ::triskele::Log log (name); { if (triskele::debug) cerr << expr << endl << flush; }
|
||||
#define DEF_LOG(name, expr) ::triskele::Log log (name); { if (::triskele::debug) cerr << expr << endl << flush; }
|
||||
#endif
|
||||
|
||||
#ifndef LOG
|
||||
#define LOG(expr) { if (triskele::debug) cerr << log << "| " << expr << endl << flush; }
|
||||
#define LOG(expr) { if (::triskele::debug) cerr << log << "| " << expr << endl << flush; }
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG(expr) { if (triskele::debug) cerr << expr << endl << flush; }
|
||||
#define DEBUG(expr) { if (::triskele::debug) cerr << expr << endl << flush; }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -94,8 +94,8 @@ namespace triskele {
|
||||
static unsigned int indent;
|
||||
string functName;
|
||||
public:
|
||||
Log (const string &functName) : functName (functName) { ++indent; if (triskele::debug) cerr << *this << "> "; }
|
||||
~Log () { if (triskele::debug) cerr << *this << "<" << endl << flush; --indent; }
|
||||
Log (const string &functName) : functName (functName) { ++indent; if (::triskele::debug) cerr << *this << "> "; }
|
||||
~Log () { if (::triskele::debug) cerr << *this << "<" << endl << flush; --indent; }
|
||||
friend inline ostream &operator << (ostream &out, const Log &log) {
|
||||
return out << getLocalTimeStr () << setw (3) << setw ((log.indent % 20)*2) << "" << log.functName;
|
||||
}
|
||||
|
@ -98,25 +98,38 @@ Option::parse (int argc, char** argv) {
|
||||
string inputFileName, outputFileName, bandsRange;
|
||||
long left = -1, top = -1, width = -1, height = -1;
|
||||
string areaThresholdsName, levelThresholdsName, sdThresholdsName, moiThresholdsName;
|
||||
bool c4 = false, c6p = false, c6n = false, c8 = false;
|
||||
try {
|
||||
desc.add_options ()
|
||||
("help", po::bool_switch (&helpFlag), "produce this help message")
|
||||
("version", po::bool_switch (&versionFlag), "display version information")
|
||||
("debug", po::bool_switch (&debugFlag), "debug mode")
|
||||
|
||||
("band,b", po::value<string> (&bandsRange), "select input band (first band is 0) (default all bands : 0-*)")
|
||||
("left,x", po::value<long> (&left), "left crop (default center)")
|
||||
("top,y", po::value<long> (&top), "top crop (default middle)")
|
||||
("width,w", po::value<long> (&width), "width crop (default input width)")
|
||||
("height,h", po::value<long> (&height), "height crop (default input height)")
|
||||
|
||||
("border", po::bool_switch (&border), "build tree without border pixels (no-data)")
|
||||
("C4", po::bool_switch (&c4), (string ("4-connected pixels")+
|
||||
(connectivity == Connectivity::C4 ? " (default)" : "")).c_str ())
|
||||
("C6P", po::bool_switch (&c6p), (string ("6-connected pixels (positive")+
|
||||
(connectivity == Connectivity::C6P ? " (default)" : "")+")").c_str ())
|
||||
("C6N", po::bool_switch (&c6n), (string ("6-connected pixels (negative")+
|
||||
(connectivity == Connectivity::C6N ? " (default)" : "")+")").c_str ())
|
||||
("C8", po::bool_switch (&c8), (string ("8-connected pixels")+
|
||||
(connectivity == Connectivity::C8 ? " (default)" : "")).c_str ())
|
||||
|
||||
("input,i", po::value<string> (&inputFileName), "input file name image")
|
||||
("output,o", po::value<string> (&outputFileName), "output file name hyperbands image (contains attributs profiles)")
|
||||
("average", po::bool_switch (&averageFlag), "produce average profiles")
|
||||
|
||||
("max-tree", po::bool_switch (&maxTreeFlag), "build max-tree")
|
||||
("min-tree", po::bool_switch (&minTreeFlag), "build min-tree")
|
||||
("tos-tree", po::bool_switch (&tosTreeFlag), "build tree-of-shape")
|
||||
("alpha-tree", po::bool_switch (&alphaTreeFlag), "build alpha-tree")
|
||||
|
||||
("average", po::bool_switch (&averageFlag), "produce average profiles")
|
||||
("level,L", po::value<string> (&levelThresholdsName), "produce level attributs")
|
||||
("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
|
||||
("standard-deviation,S", po::value<string> (&sdThresholdsName), "produce standard deviation attributs")
|
||||
@ -222,6 +235,18 @@ Option::parse (int argc, char** argv) {
|
||||
topLeft = Point ((DimSideImg) left, (DimSideImg) top);
|
||||
size = Size ((DimSideImg) width, (DimSideImg) height);
|
||||
|
||||
int connectivityCount = c4 + c6n + c6p + c8;
|
||||
if (connectivityCount > 1)
|
||||
usage ("You must choose only one connectivity model");
|
||||
if (c6p)
|
||||
connectivity = Connectivity::C6P;
|
||||
else if (c6n)
|
||||
connectivity = Connectivity::C6N;
|
||||
else if (c8)
|
||||
connectivity = Connectivity::C8;
|
||||
else
|
||||
connectivity = Connectivity::C4;
|
||||
|
||||
cout
|
||||
<< "Input:" << inputFileName << " " << orgSize << " (" << bandInputCount << " chanels of " << GDALGetDataTypeName (inputType) << ")" << endl
|
||||
<< "Crop topLeft:" << topLeft << " size:" << size << " band:" << selectedBand << endl
|
||||
|
@ -66,7 +66,7 @@ void apGenerator (Option &option) {
|
||||
if (!treeTypesCard)
|
||||
cerr << "*** no tree type ! => copy mode" << endl;
|
||||
|
||||
Border border (option.size, false); // default = no border
|
||||
Border border (option.size, option.border);
|
||||
GraphWalker graphWalker (border);
|
||||
DimImg leafCount = graphWalker.vertexMaxCount ();
|
||||
DimChanel maxThresholds = max (max (max (option.areaThresholds.size (), option.levelThresholds.size ()), option.sdThresholds.size ()), option.moiThresholds.size ());
|
||||
@ -77,6 +77,16 @@ void apGenerator (Option &option) {
|
||||
option.outputImage.createImage (option.size, option.inputImage.getDataType (), outputBandsCard);
|
||||
|
||||
Raster<PixelT> raster;
|
||||
if (option.border) {
|
||||
DimChanel bandCount (option.inputImage.getBandCount ());
|
||||
for (DimChanel band = 0; band < bandCount; ++band) {
|
||||
option.inputImage.readBand (raster, band, option.topLeft, option.size);
|
||||
for (DimImg idx = 0; idx < leafCount; ++idx)
|
||||
if (raster.getValue (idx))
|
||||
border.clearBorder (idx);
|
||||
}
|
||||
}
|
||||
|
||||
DimChanel chanel = 0;
|
||||
for (DimChanel band : option.selectedBand.getSet ()) {
|
||||
option.inputImage.readBand (raster, band, option.topLeft, option.size);
|
||||
|
Loading…
Reference in New Issue
Block a user