modifié : MakefileNoOTB

modifié :         include/Appli/Option.hpp
	modifié :         include/ArrayTree/ArrayTreeBuilder.hpp
	modifié :         include/ArrayTree/ArrayTreeBuilder.tpp
	modifié :         include/AttributeProfiles.hpp
	modifié :         include/AttributeProfiles.tpp
	modifié :         include/Attributes/AreaAttributes.hpp
	modifié :         include/Attributes/AreaAttributes.tpp
	modifié :         include/Attributes/MoIAttributes.hpp
	modifié :         include/Attributes/MoIAttributes.tpp
	modifié :         include/Attributes/SDAttributes.hpp
	modifié :         include/Attributes/SDAttributes.tpp
	modifié :         include/CompAttribute.hpp
	modifié :         include/CompAttribute.tpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/testMain.cpp
This commit is contained in:
Git Merciol 2018-02-20 16:39:24 +01:00
parent 0388624f4b
commit 300bfd965d
16 changed files with 233 additions and 97 deletions

View File

@ -46,7 +46,7 @@ libtriskele: $(LIB_DIR)/libtriskele.a
$(TST_OUT): $(TST_SRC) $(LIB_DIR)/libtriskele.a
testMain: $(TST_OUT)
$(TST_OUT) data/nairobi-byte.tif data/result.tif -b 0 -w 5 -h 5 # --debug
$(TST_OUT) data/nairobi-byte.tif data/result.tif --debug -b 0 -w 4000 -h 4000 --min-tree -A data/areaThresholds.txt
## DEPENDS #############################
ALL_OUT = $(TST_OUT)

View File

@ -22,7 +22,10 @@ namespace otb {
Point topLeft = NullPoint;
Size size = NullSize;
DimChanel chanel = 0;
unsigned int treeCoreCount = boost::thread::hardware_concurrency ();
vector<DimImg> areaThresholds;
vector<double> sdThresholds, moiThresholds;
unsigned int coreCount = boost::thread::hardware_concurrency ();
bool maxTreeFlag = false, minTreeFlag = false, tosTreeFlag = false;
Option ();
Option (int argc, char** argv);

View File

@ -40,7 +40,7 @@ namespace otb {
inline ~ArrayTreeBuilder ();
inline void buildTree (Tree &tree, WeightAttributes<WeightT> &weightAttributes);
inline void setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const Raster<PixelT> &raster);
inline void setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles);
protected:
template<typename WeightFunct>
inline void

View File

@ -38,16 +38,17 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
compWeights = weightAttributes.getValues ();
switch (type) {
// case MIN:
// buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
case MIN:
buildTree (tree, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
case MAX:
buildTree (tree, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
// case TOS:
// buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
case TOS:
buildTree (tree, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
break;
// XXX msg
default:
cerr << "*** unknown tree type: " << type << endl;
}
weightAttributes.setWeightBounds (tree);
leaders.free ();
@ -59,20 +60,21 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, WeightAttributes<Weigh
// ========================================
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles, const Raster<PixelT> &raster) {
ArrayTreeBuilder<WeightT, PixelT>::setAttributProfiles (AttributeProfiles<PixelT> &attributeProfiles) {
DEF_LOG ("ArrayTreeBuilder::setAttributProfiles", "");
attributeProfiles.updateTranscient ();
switch (type) {
// case MIN:
// setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
case MIN:
setAttributProfiles (attributeProfiles, MinWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
case MAX:
setAttributProfiles (attributeProfiles, MaxWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
break;
// case TOS:
// setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), raster.getSize ()));
case TOS:
setAttributProfiles (attributeProfiles, MedianWeight<PixelT, WeightT> (raster.getPixels (), graphWalker));
break;
// XXX msg
default:
cerr << "*** unknown tree type: " << type << endl;
}
}

View File

@ -14,6 +14,7 @@ namespace otb {
inline void updateTranscient ();
inline PixelT *getValues ();
inline const PixelT *getValues () const;
inline void printValues () const;
protected:

View File

@ -28,6 +28,12 @@ AttributeProfiles<PixelT>::getValues () {
return values;
}
template<typename PixelT>
inline const PixelT *
AttributeProfiles<PixelT>::getValues () const {
return values;
}
template<typename PixelT>
inline void
AttributeProfiles<PixelT>::printValues () const {

View File

@ -11,6 +11,10 @@ namespace otb {
public:
inline AreaAttributes (const Tree &tree);
inline ~AreaAttributes ();
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<DimImg> &thresholds) const;
protected:
inline void compute ();
};

View File

@ -11,6 +11,13 @@ inline
AreaAttributes::~AreaAttributes () {
}
template<typename PixelT>
inline void
AreaAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<DimImg> &thresholds) const {
CompAttributeC<DimImg>::cut (allBands, attributeProfiles, 1, thresholds);
}
inline void
AreaAttributes::compute () {
computeSameCompLevel ([this] (const DimImg &parentId) {

View File

@ -11,6 +11,10 @@ namespace otb {
public:
inline MoIAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
inline ~MoIAttributes ();
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const;
protected:
inline void compute (const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes);
};

View File

@ -11,6 +11,15 @@ inline
MoIAttributes::~MoIAttributes () {
}
template<typename PixelT>
inline void
MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const {
DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ());
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ()));
}
inline void
MoIAttributes::compute (const AreaAttributes &areaAttributes, const XYAttributes &xyAttributes) {
const AverageXY *xy = xyAttributes.getValues ();

View File

@ -1,6 +1,7 @@
#ifndef _OTB_TRISKELE_SD_ATTRIBUTES_HPP
#define _OTB_TRISKELE_SD_ATTRIBUTES_HPP
#include "triskeleDebug.hpp"
#include "triskeleBase.hpp"
#include "CompAttribute.hpp"
#include "Attributes/AreaAttributes.hpp"
@ -12,6 +13,10 @@ namespace otb {
public:
inline SDAttributes (const Tree &tree, const AreaAttributes &areaAttributes);
inline ~SDAttributes ();
template<typename PixelT>
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const;
protected:
inline void compute (const AreaAttributes &areaAttributes);
};

View File

@ -11,6 +11,15 @@ inline
SDAttributes::~SDAttributes () {
}
template<typename PixelT>
inline void
SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const {
DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ());
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ()));
}
inline void
SDAttributes::compute (const AreaAttributes &areaAttributes) {
const DimImg *areas = areaAttributes.getValues ();

View File

@ -3,6 +3,7 @@
#include <vector>
#include "triskeleDebug.hpp"
#include "triskeleBase.hpp"
#include "Tree.hpp"
#include "AttributeProfiles.hpp"
@ -19,6 +20,7 @@ namespace otb {
inline void updateTranscient ();
inline const AttrT *getValues () const;
inline AttrT *getValues ();
inline AttrT getMaxValue () const;
inline void printValues (const string &msg) const;
protected:
@ -38,30 +40,25 @@ namespace otb {
namespace otb {
namespace triskele {
template <typename AttrT>
struct ThresholdsChanel {
AttrT threshold;
DimChanel chanel;
ThresholdsChanel (const AttrT &threshold, const DimChanel &chanel) : threshold (threshold), chanel (chanel) {}
};
template<typename AttrT>
class CompAttributeC : public CompAttribute<AttrT> {
public:
inline CompAttributeC (const Tree &tree);
inline ~CompAttributeC ();
template<typename PixelT>
inline void cut (vector<vector<PixelT> > allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const AttrT &pixelAttrValue, const vector<const ThresholdsChanel<AttrT> > &selection);
static inline vector<AttrT> getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue);
template<typename PixelT>
inline void cutOnPos (vector<vector<PixelT> > allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const DimImg &pixelId, const AttrT &pixelAttrValue, const vector<const ThresholdsChanel<AttrT> > &selection);
inline void cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
template<typename PixelT>
inline void cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const DimImg &pixelId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const;
protected:
template<typename CumpFunctPSE>
inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/);
inline void computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE /* cumpFunctPSE (DimImg parentId)*/) const;
};
#include "CompAttribute.tpp"

View File

@ -34,6 +34,18 @@ CompAttribute<AttrT>::getValues () {
return values;
}
template<typename AttrT>
inline AttrT
CompAttribute<AttrT>::getMaxValue () const {
if (!leafCount)
return 0;
AttrT max = values[0];
CompAttribute<AttrT>::tree.forEachComp ([this, &max] (const DimImg &compId) {
if (values[compId] > max)
max = values[compId];
});
return max;
}
template<typename AttrT>
inline void
@ -75,13 +87,25 @@ inline
CompAttributeC<AttrT>::~CompAttributeC () {
}
template<typename AttrT>
inline vector<AttrT>
CompAttributeC<AttrT>::getScaledThresholds (const vector<double> &thresholds, const AttrT &maxValue) {
vector<AttrT> result;
for (AttrT percent : thresholds)
result.push_back (percent*maxValue);
return result;
}
template<typename AttrT>
template<typename CumpFunctPSE>
inline void
CompAttributeC<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) {
CompAttributeC<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) const {
const vector<DimImg> &weightBounds (CompAttribute<AttrT>::tree.getWeightBounds ());
unsigned int coreCount = CompAttribute<AttrT>::tree.getCoreCount ();
DEF_LOG ("CompAttributeC::computeSameCompLevel", "coreCount:" << coreCount);
if (!weightBounds.size () || CompAttribute<AttrT>::tree.getCompCount ()/weightBounds.size () < coreCount) {
LOG ("CompAttributeC::computeSameCompLevel: no thread");
CompAttribute<AttrT>::tree.forEachComp (cumpFunctPSE);
return;
}
@ -99,51 +123,54 @@ CompAttributeC<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) {
template<typename AttrT>
template<typename PixelT>
inline void
CompAttributeC<AttrT>::cut (vector<vector<PixelT> > allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const AttrT &pixelAttrValue, const vector<const ThresholdsChanel<AttrT> > &selection) {
dealThreadRange (CompAttribute<AttrT>::leafCount, CompAttribute<AttrT>::coreCount, [this, &allBands, &attributeProfiles, &pixelAttrValue, &selection] (const DimImg &leafId) {
cutOnPos (allBands, attributeProfiles, leafId, pixelAttrValue, selection);
CompAttributeC<AttrT>::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
DEF_LOG ("CompAttributeC::cut", "coreCount:" << CompAttribute<AttrT>::tree.getCoreCount () << " thresholds:" << thresholds.size ());
dealThreadRange (CompAttribute<AttrT>::leafCount, CompAttribute<AttrT>::tree.getCoreCount (), [this, &allBands, &attributeProfiles, &pixelAttrValue, &thresholds] (const DimImg &leafId) {
cutOnPos (allBands, attributeProfiles, leafId, pixelAttrValue, thresholds);
});
}
template<typename AttrT>
template<typename PixelT>
inline void
CompAttributeC<AttrT>::cutOnPos (vector<vector<PixelT> > allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const DimImg &leafId, const AttrT &pixelAttrValue, const vector<const ThresholdsChanel<AttrT> > &selection) {
CompAttributeC<AttrT>::cutOnPos (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const DimImg &leafId, const AttrT &pixelAttrValue, const vector<AttrT> &thresholds) const {
// no debug (to many pixels)
DimImg parentId = CompAttribute<AttrT>::tree.getLeafParents (leafId);
DimChanel selectionSize = selection.size ();
DimImg parentId = CompAttribute<AttrT>::tree.getLeafParent (leafId);
DimChanel thresholdsSize = thresholds.size ();
if (parentId == DimImg_MAX) {
for (DimChanel i = 0; i < selectionSize; ++i)
allBands[leafId][selection[i].chanel] = 0;
for (DimChanel chanel = 0; chanel < thresholdsSize; ++chanel)
allBands[chanel][leafId] = 0;
return;
}
DimNodeId nodeId = leafId, curId = 0;
DimNodeId nodeId = leafId;
DimImg curId = 0;
AttrT curValue = pixelAttrValue;
if (curValue == CompAttribute<AttrT>::values [parentId]) {
// skip pixel on flat zone
curId = parentId;
nodeId = curId+CompAttribute<AttrT>::leafCount;
nodeId = ((DimNodeId)curId)+CompAttribute<AttrT>::leafCount;
parentId = CompAttribute<AttrT>::tree.getCompParent (curId);
}
const PixelT *apValues = attributeProfiles.getValues ();
DimImg rootId = CompAttribute<AttrT>::tree.getCompRoot ();
for (DimChanel i = 0; i < selectionSize; ++i) {
AttrT ceil = selection[i].threshold;
for (DimChanel chanel = 0; chanel < thresholdsSize; ++chanel) {
AttrT ceil = thresholds[chanel];
for ( ; curValue < ceil && curId < rootId; ) {
if (parentId == DimImg_MAX || curId >= parentId) {
// XXX root
for (; i < selectionSize; ++i)
allBands[leafId][selection[i].chanel] = 0;
// cerr << "CompAttributeC::cutOnPos find sub-root:" << rootId << " rootId:" << rootId << endl;
for (; chanel < thresholdsSize; ++chanel)
allBands[chanel][leafId] = curValue;
return;
}
nodeId = CompAttribute<AttrT>::tree.getLeafParents (nodeId)+CompAttribute<AttrT>::leafCount;
nodeId = ((DimNodeId) CompAttribute<AttrT>::tree.getLeafParent (nodeId))+CompAttribute<AttrT>::leafCount;
curId = parentId;
curValue = CompAttribute<AttrT>::values [curId];
parentId = CompAttribute<AttrT>::tree.getCompParents (curId);
parentId = CompAttribute<AttrT>::tree.getCompParent (curId);
}
// XXX si valeur > root ?
allBands[leafId][selection[i].chanel] = attributeProfiles [nodeId];
allBands[chanel][leafId] = apValues [nodeId];
}
}

View File

@ -7,6 +7,7 @@
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/filesystem.hpp>
#include "triskeleDebug.hpp"
#include "triskeleBase.hpp"
@ -18,9 +19,36 @@
#endif
using namespace std;
using namespace boost::filesystem;
using namespace triskele;
using namespace otb::triskele;
// ========================================
template<typename T>
vector<T>
readThresholds (string fileName) {
vector<T> thresholds;
if (fileName.empty ()) {
return thresholds;
}
std::ifstream ifs;
ifs.open (fileName);
string line;
while (getline (ifs, line)) {
stringstream ss (line);
T value;
ss >> value;
if (ss.fail ())
continue;
thresholds.push_back (value);
}
if (!thresholds.size ())
cerr << "*** readThresholds: empty file: " << fileName << endl;
sort (thresholds.begin (), thresholds.end ());
return thresholds;
}
// ========================================
Option::Option () {
}
@ -69,6 +97,7 @@ Option::parse (int argc, char** argv) {
bool helpFlag = false, versionFlag = false, useTheForceLuke = false;
string inputFileName, outputFileName;
long left = -1, top = -1, width = -1, height = -1;
string areaThresholdsName, sdThresholdsName, moiThresholdsName;
try {
desc.add_options ()
("help", po::bool_switch (&helpFlag), "produce this help message")
@ -82,14 +111,16 @@ Option::parse (int argc, char** argv) {
("height,h", po::value<long> (&height), "height crop (default input height)")
("input,i", po::value<string> (&inputFileName), "input file name image")
("output,o", po::value<string> (&outputFileName), "output file name hyperbands image (contains attributs profiles)")
//("min-tree", po::bool_switch (&options.noTreeFlag[minE]), "build min-tree")
//("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
("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")
("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
("standard-deviation,S", po::value<string> (&sdThresholdsName), "produce standard deviation attributs")
("moment-of-inertia,M", po::value<string> (&moiThresholdsName), "produce moment of inertia attributs")
;
hide.add_options ()
("use-the-force-luke", po::bool_switch (&useTheForceLuke), "display hidded options")
("tree-core-count", po::value<unsigned int> (&treeCoreCount), "thread used to build tree (default hardware value)")
// ("max-tree", po::bool_switch (&options.noTreeFlag[maxE]), "build max-tree")
// ("tos-tree", po::bool_switch (&options.noTreeFlag[tosE]), "build tree-of-shape")
("tree-core-count", po::value<unsigned int> (&coreCount), "thread used to build tree (default hardware value)")
// ("standard-deviation,S", po::value<string> (&sdThresholdsName), "produce standard deviation attributs")
// ("moment-of-inertia,I", po::value<string> (&moiThresholdsName), "produce moment of inertia attributs")
// ("no-border", po::bool_switch (&options.noBorder), "build tree with all pixels (included no-data)")
@ -111,7 +142,6 @@ Option::parse (int argc, char** argv) {
p.add (inputFileC, -1);
po::variables_map vm;
po::store (po::command_line_parser (argc, argv).options (cmd).positional (p).run (), vm);
po::store (po::command_line_parser (argc, argv).options (desc).positional (p).run (), vm);
po::notify (vm);
if (useTheForceLuke)
@ -150,6 +180,10 @@ Option::parse (int argc, char** argv) {
} catch (...) {
usage ("Bad options");
}
areaThresholds = readThresholds<DimImg> (areaThresholdsName);
sdThresholds = readThresholds<double> (sdThresholdsName);
moiThresholds = readThresholds<double> (moiThresholdsName);
inputImage.setFileName (inputFileName);
outputImage.setFileName (outputFileName);
inputImage.readImage ();

View File

@ -32,47 +32,74 @@ using namespace otb::triskele::arrayTree;
template<typename PixelT>
inline
void prog (Option &option) {
Raster<PixelT> raster;
option.inputImage.readBand (raster, option.chanel, option.topLeft, option.size);
void apGenerator (Option &option) {
vector<TreeType> treeTypes;
if (option.minTreeFlag)
treeTypes.push_back (MIN);
if (option.maxTreeFlag)
treeTypes.push_back (MAX);
if (option.tosTreeFlag)
treeTypes.push_back (TOS);
DimChanel treeTypesCard = treeTypes.size ();
if (!treeTypesCard)
cerr << "*** no tree type ! => copy mode" << endl;
Border border; // default = no border
GraphWalker graphWalker (raster.getSize (), border);
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, TreeType::MAX);
Tree tree (option.treeCoreCount);
GraphWalker graphWalker (option.size, 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));
DimChanel outputBandsCard = 1+treeTypesCard*(option.areaThresholds.size ()+option.sdThresholds.size ()+option.moiThresholds.size ()); // XXX * bands
option.outputImage.createImage (option.size, option.inputImage.getDataType (), outputBandsCard);
Raster<PixelT> raster;
DimChanel chanel = 0;
// XXX band loop
DimChanel band = option.chanel;
option.inputImage.readBand (raster, band, option.topLeft, option.size);
option.outputImage.writeBand (raster.getPixels (), chanel++);
for (TreeType treeType : treeTypes) {
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, treeType);
Tree tree (option.coreCount);
WeightAttributes<PixelT> weightAttributes (tree);
atb.buildTree (tree, weightAttributes);
weightAttributes.printValues ("weight");
tree.printTree ();
AttributeProfiles<PixelT> attributeProfiles (tree);
atb.setAttributProfiles (attributeProfiles, raster);
attributeProfiles.printValues ();
atb.setAttributProfiles (attributeProfiles);
AreaAttributes areaAttributes (tree);
areaAttributes.printValues ("area");
AverageAttributes averageAttributes (tree, raster, areaAttributes);
averageAttributes.printValues ("average");
areaAttributes.cut (allBands, attributeProfiles, option.areaThresholds);
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
option.outputImage.writeBand (&allBands[c][0], chanel);
{ // free SDAttributes after use
SDAttributes sdAttributes (tree, areaAttributes);
sdAttributes.printValues ("sd");
sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);
for (DimChanel c = 0; c < option.sdThresholds.size (); ++c, ++chanel)
option.outputImage.writeBand (&allBands[c][0], chanel);
}
{ // free MoIAttributes after use
XYAttributes xyAttributes (tree, areaAttributes);
//xyAttributes.printValues ("XY"); // pb print de complexe
MoIAttributes moiAttributes (tree, areaAttributes, xyAttributes);
moiAttributes.printValues ("moi");
moiAttributes.cut (allBands, attributeProfiles, option.moiThresholds);
for (DimChanel c = 0; c < option.moiThresholds.size (); ++c, ++chanel)
option.outputImage.writeBand (&allBands[c][0], chanel);
}
}
// XXX cut allProfiles.clear ();
DimChanel nbBands = 1;
vector <vector <PixelT> > allBands (tree.getLeafCount (), vector<PixelT> (nbBands, 0));
//weightAttributes.printValues ("weight");
//tree.printTree ();
//attributeProfiles.printValues ();
//areaAttributes.printValues ("area");
// AverageAttributes averageAttributes (tree, raster, areaAttributes);
// averageAttributes.printValues ("average");
// sdAttributes.printValues ("sd");
// //xyAttributes.printValues ("XY"); // pb print de complexe
// moiAttributes.printValues ("moi");
// attribute.cut (out, attributProfiles, threshold)
// XXX write
option.outputImage.createImage (tree.getSize (), option.inputImage.getDataType (), nbBands);
for (DimChanel c = 0; c < nbBands; ++c)
option.outputImage.writeBand (&allBands[c][0], c);
cerr << endl << "*** prog ok!" << endl;
cerr << endl << "*** apGenerator done!" << endl;
}
int
@ -82,20 +109,21 @@ main (int argc, char** argv, char** envp) {
switch (option.inputImage.getDataType ()) {
case GDT_Byte:
prog<uint8_t> (option); break;
apGenerator<uint8_t> (option); break;
// case GDT_UInt16:
// prog<uint16_t> (option); break;
// apGenerator<uint16_t> (option); break;
// case GDT_Int16:
// prog<int16_t> (option); break;
// apGenerator<int16_t> (option); break;
// case GDT_UInt32:
// prog<uint32_t> (option); break;
// apGenerator<uint32_t> (option); break;
// case GDT_Int32:
// prog<int32_t> (option); break;
// apGenerator<int32_t> (option); break;
// case GDT_Float32:
// prog<float> (option); break;
// apGenerator<float> (option); break;
// case GDT_Float64:
// prog<double> (option); break;
// apGenerator<double> (option); break;
default :
cerr << "unknown type!" << endl; break;
return 1;