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 $(TST_OUT): $(TST_SRC) $(LIB_DIR)/libtriskele.a
testMain: $(TST_OUT) 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 ############################# ## DEPENDS #############################
ALL_OUT = $(TST_OUT) 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} DEPENDS = ${ALL_OUT:=.d} ${ALL_OBJ:.o=.d}
-include ${DEPENDS} -include ${DEPENDS}

View File

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

View File

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

View File

@ -16,8 +16,10 @@ inline void
MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles, MoIAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const { const vector<double> &thresholds) const {
DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ()); 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>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ())); CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
} }
inline void inline void

View File

@ -16,8 +16,10 @@ inline void
SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles, SDAttributes::cut (vector<vector<PixelT> > &allBands, const AttributeProfiles<PixelT> &attributeProfiles,
const vector<double> &thresholds) const { const vector<double> &thresholds) const {
DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ()); 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>::cut (allBands, attributeProfiles, 0,
CompAttributeC<double>::getScaledThresholds (thresholds, CompAttribute<double>::getMaxValue ())); CompAttributeC<double>::getScaledThresholds (thresholds, maxValue));
} }
inline void inline void

View File

@ -95,7 +95,7 @@ void
Option::parse (int argc, char** argv) { Option::parse (int argc, char** argv) {
prog = argv [0]; prog = argv [0];
bool helpFlag = false, versionFlag = false, useTheForceLuke = false; bool helpFlag = false, versionFlag = false, useTheForceLuke = false;
string inputFileName, outputFileName; string inputFileName, outputFileName, bandsRange;
long left = -1, top = -1, width = -1, height = -1; long left = -1, top = -1, width = -1, height = -1;
string areaThresholdsName, sdThresholdsName, moiThresholdsName; string areaThresholdsName, sdThresholdsName, moiThresholdsName;
try { try {
@ -103,8 +103,7 @@ Option::parse (int argc, char** argv) {
("help", po::bool_switch (&helpFlag), "produce this help message") ("help", po::bool_switch (&helpFlag), "produce this help message")
("version", po::bool_switch (&versionFlag), "display version information") ("version", po::bool_switch (&versionFlag), "display version information")
("debug", po::bool_switch (&debugFlag), "debug mode") ("debug", po::bool_switch (&debugFlag), "debug mode")
("band,b", po::value<DimChanel> (&chanel), (string ("select input band (first band is 0) (default ")+ ("band,b", po::value<string> (&bandsRange), "select input band (first band is 0) (default all bands : 0-*)")
boost::lexical_cast<std::string> (chanel)+")").c_str ())
("left,x", po::value<long> (&left), "left crop (default center)") ("left,x", po::value<long> (&left), "left crop (default center)")
("top,y", po::value<long> (&top), "top crop (default middle)") ("top,y", po::value<long> (&top), "top crop (default middle)")
("width,w", po::value<long> (&width), "width crop (default input width)") ("width,w", po::value<long> (&width), "width crop (default input width)")
@ -169,6 +168,7 @@ Option::parse (int argc, char** argv) {
if (inputFileName.empty ()) if (inputFileName.empty ())
inputFileName = var [--required]; inputFileName = var [--required];
} }
selectedBand = Selected (bandsRange);
if (debugFlag) { if (debugFlag) {
#ifndef ENABLE_LOG #ifndef ENABLE_LOG
@ -191,8 +191,8 @@ Option::parse (int argc, char** argv) {
GDALDataType inputType = inputImage.getDataType (); GDALDataType inputType = inputImage.getDataType ();
int bandInputCount = inputImage.getBandCount (); int bandInputCount = inputImage.getBandCount ();
if (!(chanel < bandInputCount)) selectedBand.setLimits (0, bandInputCount-1);
TRISKELE_ERROR ("chanel " << chanel << " out of " << bandInputCount << " bands!"); selectedBand.toSet ();
Size orgSize = inputImage.getSize (); Size orgSize = inputImage.getSize ();
if (width < 0 || width > orgSize.width) if (width < 0 || width > orgSize.width)
@ -212,6 +212,10 @@ Option::parse (int argc, char** argv) {
cout cout
<< "Input :" << inputFileName << " " << orgSize << " (" << bandInputCount << " chanels of " << GDALGetDataTypeName (inputType) << ")" << endl << "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; << "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,8 +56,7 @@ void apGenerator (Option &option) {
Raster<PixelT> raster; Raster<PixelT> raster;
DimChanel chanel = 0; DimChanel chanel = 0;
// XXX band loop for (DimChanel band : option.selectedBand.getSet ()) {
DimChanel band = option.chanel;
option.inputImage.readBand (raster, band, option.topLeft, option.size); option.inputImage.readBand (raster, band, option.topLeft, option.size);
option.outputImage.writeBand (raster.getPixels (), chanel++); option.outputImage.writeBand (raster.getPixels (), chanel++);
@ -88,7 +87,7 @@ void apGenerator (Option &option) {
option.outputImage.writeBand (&allBands[c][0], chanel); option.outputImage.writeBand (&allBands[c][0], chanel);
} }
} }
}
//weightAttributes.printValues ("weight"); //weightAttributes.printValues ("weight");
//tree.printTree (); //tree.printTree ();
//attributeProfiles.printValues (); //attributeProfiles.printValues ();
@ -111,18 +110,18 @@ main (int argc, char** argv, char** envp) {
case GDT_Byte: case GDT_Byte:
apGenerator<uint8_t> (option); break; apGenerator<uint8_t> (option); break;
// case GDT_UInt16: case GDT_UInt16:
// apGenerator<uint16_t> (option); break; apGenerator<uint16_t> (option); break;
// case GDT_Int16: case GDT_Int16:
// apGenerator<int16_t> (option); break; apGenerator<int16_t> (option); break;
// case GDT_UInt32: case GDT_UInt32:
// apGenerator<uint32_t> (option); break; apGenerator<uint32_t> (option); break;
// case GDT_Int32: case GDT_Int32:
// apGenerator<int32_t> (option); break; apGenerator<int32_t> (option); break;
// case GDT_Float32: case GDT_Float32:
// apGenerator<float> (option); break; apGenerator<float> (option); break;
// case GDT_Float64: case GDT_Float64:
// apGenerator<double> (option); break; apGenerator<double> (option); break;
default : default :
cerr << "unknown type!" << endl; break; cerr << "unknown type!" << endl; break;