modifié : MakefileNoOTB

modifié :         include/Appli/Option.hpp
	modifié :         include/ArrayTree/GraphWalker.hpp
	modifié :         include/Attributes/MoIAttributes.tpp
	modifié :         include/Attributes/SDAttributes.tpp
	modifié :         src/Appli/Option.cpp
	modifié :         src/testMain.cpp
This commit is contained in:
Git Merciol 2018-02-20 18:25:40 +01:00
parent 300bfd965d
commit a2d21182a7
7 changed files with 62 additions and 52 deletions

View File

@ -46,11 +46,14 @@ 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 --debug -b 0 -w 4000 -h 4000 --min-tree -A data/areaThresholds.txt
# $(TST_OUT) data/nairobi-byte.tif data/result.tif -b 0 -w 4000 -h 4000 --min-tree -A data/areaThresholds.txt # --debug
# $(TST_OUT) data/10m.tif data/result.tif -b 0 --min-tree --max-tree --tos-tree -A data/areaThresholds.txt -S data/sdThresholds.txt -M data/moiThresholds.txt # --debug
$(TST_OUT) data/10m.tif data/result.tif -b 0 --min-tree --max-tree --tos-tree -S data/sdThresholds.txt # --debug
## DEPENDS #############################
ALL_OUT = $(TST_OUT)
ALL_OBJ = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/XMLTreeBuilder.o $(OBJ_DIR)/Option.o
ALL_OBJ = $(OBJ_DIR)/IImage.o $(OBJ_DIR)/triskeleArrayTreeBase.o $(OBJ_DIR)/Tree.o $(OBJ_DIR)/triskeleDebug.o $(OBJ_DIR)/triskeleBase.o $(OBJ_DIR)/QuadTreeBuilder.o $(OBJ_DIR)/XMLTreeBuilder.o $(OBJ_DIR)/Option.o $(OBJ_DIR)/Selected.o
DEPENDS = ${ALL_OUT:=.d} ${ALL_OBJ:.o=.d}
-include ${DEPENDS}

View File

@ -7,6 +7,7 @@
#include "triskeleBase.hpp"
#include "IImage.hpp"
#include "Appli/Selected.hpp"
namespace otb {
namespace triskele {
@ -21,7 +22,7 @@ namespace otb {
IImage outputImage;
Point topLeft = NullPoint;
Size size = NullSize;
DimChanel chanel = 0;
Selected selectedBand;
vector<DimImg> areaThresholds;
vector<double> sdThresholds, moiThresholds;
unsigned int coreCount = boost::thread::hardware_concurrency ();

View File

@ -69,7 +69,6 @@ namespace otb {
#include "GraphWalker.tpp"
} // arrayTree
} // triskele
} // otb

View File

@ -16,8 +16,10 @@ inline void
MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const {
DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ());
double maxValue = CompAttribute<double>::getMaxValue ();
cerr << "moi max value:" << maxValue << endl;
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ()));
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
}
inline void

View File

@ -16,8 +16,10 @@ inline void
SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const {
DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ());
double maxValue = CompAttribute<double>::getMaxValue ();
cerr << "sd max value:" << maxValue << endl;
CompAttributeC<double>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ()));
CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
}
inline void

View File

@ -95,7 +95,7 @@ void
Option::parse (int argc, char** argv) {
prog = argv [0];
bool helpFlag = false, versionFlag = false, useTheForceLuke = false;
string inputFileName, outputFileName;
string inputFileName, outputFileName, bandsRange;
long left = -1, top = -1, width = -1, height = -1;
string areaThresholdsName, sdThresholdsName, moiThresholdsName;
try {
@ -103,8 +103,7 @@ Option::parse (int argc, char** argv) {
("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<DimChanel> (&chanel), (string ("select input band (first band is 0) (default ")+
boost::lexical_cast<std::string> (chanel)+")").c_str ())
("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)")
@ -169,6 +168,7 @@ Option::parse (int argc, char** argv) {
if (inputFileName.empty ())
inputFileName = var [--required];
}
selectedBand = Selected (bandsRange);
if (debugFlag) {
#ifndef ENABLE_LOG
@ -191,8 +191,8 @@ Option::parse (int argc, char** argv) {
GDALDataType inputType = inputImage.getDataType ();
int bandInputCount = inputImage.getBandCount ();
if (!(chanel < bandInputCount))
TRISKELE_ERROR ("chanel " << chanel << " out of " << bandInputCount << " bands!");
selectedBand.setLimits (0, bandInputCount-1);
selectedBand.toSet ();
Size orgSize = inputImage.getSize ();
if (width < 0 || width > orgSize.width)
@ -212,6 +212,10 @@ Option::parse (int argc, char** argv) {
cout
<< "Input :" << inputFileName << " " << orgSize << " (" << bandInputCount << " chanels of " << GDALGetDataTypeName (inputType) << ")" << endl
<< "Crop topLeft:" << topLeft << " size:" << size << " band:" << chanel << endl
<< "Crop topLeft:" << topLeft << " size:" << size << " band:" << selectedBand << endl
<< "Output :" << outputFileName << endl;
if (!selectedBand.empty () &&
(selectedBand.first () < 0 ||
selectedBand.last () >= bandInputCount))
TRISKELE_ERROR ("Band out of image (0 <= " << selectedBand.first () << " " << selectedBand.last () << " " << selectedBand << " < " << bandInputCount << ")");
}

View File

@ -56,39 +56,38 @@ void apGenerator (Option &option) {
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 (DimChanel band : option.selectedBand.getSet ()) {
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);
AttributeProfiles<PixelT> attributeProfiles (tree);
atb.setAttributProfiles (attributeProfiles);
for (TreeType treeType : treeTypes) {
ArrayTreeBuilder<PixelT, PixelT> atb (raster, graphWalker, treeType);
Tree tree (option.coreCount);
WeightAttributes<PixelT> weightAttributes (tree);
atb.buildTree (tree, weightAttributes);
AttributeProfiles<PixelT> attributeProfiles (tree);
atb.setAttributProfiles (attributeProfiles);
AreaAttributes areaAttributes (tree);
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.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);
MoIAttributes moiAttributes (tree, areaAttributes, xyAttributes);
moiAttributes.cut (allBands, attributeProfiles, option.moiThresholds);
for (DimChanel c = 0; c < option.moiThresholds.size (); ++c, ++chanel)
AreaAttributes areaAttributes (tree);
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.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);
MoIAttributes moiAttributes (tree, areaAttributes, xyAttributes);
moiAttributes.cut (allBands, attributeProfiles, option.moiThresholds);
for (DimChanel c = 0; c < option.moiThresholds.size (); ++c, ++chanel)
option.outputImage.writeBand (&allBands[c][0], chanel);
}
}
}
//weightAttributes.printValues ("weight");
//tree.printTree ();
//attributeProfiles.printValues ();
@ -111,18 +110,18 @@ main (int argc, char** argv, char** envp) {
case GDT_Byte:
apGenerator<uint8_t> (option); break;
// case GDT_UInt16:
// apGenerator<uint16_t> (option); break;
// case GDT_Int16:
// apGenerator<int16_t> (option); break;
// case GDT_UInt32:
// apGenerator<uint32_t> (option); break;
// case GDT_Int32:
// apGenerator<int32_t> (option); break;
// case GDT_Float32:
// apGenerator<float> (option); break;
// case GDT_Float64:
// apGenerator<double> (option); break;
case GDT_UInt16:
apGenerator<uint16_t> (option); break;
case GDT_Int16:
apGenerator<int16_t> (option); break;
case GDT_UInt32:
apGenerator<uint32_t> (option); break;
case GDT_Int32:
apGenerator<int32_t> (option); break;
case GDT_Float32:
apGenerator<float> (option); break;
case GDT_Float64:
apGenerator<double> (option); break;
default :
cerr << "unknown type!" << endl; break;