nouveau fichier : data/levelThresholds.txt

modifié :         include/Appli/Option.hpp
	modifié :         include/AttributeProfiles.hpp
	modifié :         include/AttributeProfiles.tpp
	modifié :         include/Attributes/AverageAttributes.hpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/apGenerator.cpp
This commit is contained in:
Git Merciol 2018-04-20 16:27:52 +02:00
parent aff93d5467
commit 7722357a1b
7 changed files with 50 additions and 7 deletions

8
data/levelThresholds.txt Normal file
View File

@ -0,0 +1,8 @@
0
1
5
10
25
50
100
200

View File

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

View File

@ -16,6 +16,9 @@ namespace otb {
inline PixelT *getValues ();
inline const PixelT *getValues () const;
template<typename WeightT>
inline void setValues (const PixelT *pixels, const WeightT *weights);
protected:
const Tree &tree;
DimNodeId leafCount;

View File

@ -1,6 +1,7 @@
#ifndef _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP
#define _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP
// ========================================
template<typename PixelT>
inline
AttributeProfiles<PixelT>::AttributeProfiles (const Tree &tree)
@ -34,6 +35,25 @@ AttributeProfiles<PixelT>::getValues () const {
return &values[0];
}
// ========================================
template<typename PixelT>
template<typename WeightT>
inline void
AttributeProfiles<PixelT>::setValues (const PixelT *pixels, const WeightT *weights) {
updateTranscient ();
PixelT *leafAP = &values[0];
dealThreadBound (tree.getLeafCount (), tree.getCoreCount (), [&leafAP, &pixels] (const DimImg &minVal, const DimImg &maxVal) {
for (DimImg i = minVal; i < maxVal; ++i)
leafAP[i] = pixels [i];
});
PixelT *compAP = leafAP+tree.getLeafCount ();
dealThreadBound (tree.getCompCount (), tree.getCoreCount (), [&compAP, &weights] (const DimImg &minVal, const DimImg &maxVal) {
for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx)
compAP[compIdx] = weights[compIdx];
});
}
template<typename PixelT>
inline void
AttributeProfiles<PixelT>::free () {
@ -58,4 +78,5 @@ AttributeProfiles<PixelT>::print (ostream &out) const {
return out;
}
// ========================================
#endif // _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP

View File

@ -16,6 +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"); return out; }
protected:
template<typename PixelT>

View File

@ -110,12 +110,15 @@ 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)")
("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")
("area,A", po::value<string> (&areaThresholdsName), "produce area attributs")
("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")
("moment-of-inertia,M", po::value<string> (&moiThresholdsName), "produce moment of inertia attributs")
;

View File

@ -88,20 +88,26 @@ void apGenerator (Option &option) {
WeightAttributes<PixelT> weightAttributes (tree);
atb.buildTree (tree, weightAttributes);
AttributeProfiles<PixelT> attributeProfiles (tree);
atb.setAttributProfiles (attributeProfiles);
AreaAttributes areaAttributes (tree);
if (option.areaThresholds.size ()) {
areaAttributes.cut (allBands, attributeProfiles, option.areaThresholds);
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
writeBand (option, &allBands[c][0], chanel);
}
AverageAttributes averageAttributes (tree, raster, areaAttributes);
if (option.averageFlag)
attributeProfiles.setValues (raster.getPixels (), weightAttributes.getValues ());
else
atb.setAttributProfiles (attributeProfiles);
if (option.levelThresholds.size ()) {
vector<PixelT> thresholds (weightAttributes.getConvertedThresholds (option.levelThresholds));
weightAttributes.cut (allBands, attributeProfiles, thresholds);
for (DimChanel c = 0; c < option.levelThresholds.size (); ++c, ++chanel)
writeBand (option, &allBands[c][0], chanel);
}
if (option.areaThresholds.size ()) {
areaAttributes.cut (allBands, attributeProfiles, option.areaThresholds);
for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel)
writeBand (option, &allBands[c][0], chanel);
}
if (option.sdThresholds.size ()) {
SDAttributes sdAttributes (tree, areaAttributes);
sdAttributes.cut (allBands, attributeProfiles, option.sdThresholds);