diff --git a/MakefileNoOTB b/MakefileNoOTB index 9032254..eac03cb 100644 --- a/MakefileNoOTB +++ b/MakefileNoOTB @@ -48,7 +48,7 @@ $(TST_OUT): $(TST_SRC) $(LIB_DIR)/libtriskele.a testMain: $(TST_OUT) # $(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 -A data/areaThresholds.txt -S data/sdThresholds.txt -M data/moiThresholds.txt # --debug + $(TST_OUT) data/10m.tif data/result.tif --min-tree --max-tree --tos-tree -A data/areaThresholds.txt -S data/sdThresholds.txt -M data/moiThresholds.txt # --debug ## DEPENDS ############################# diff --git a/include/Attributes/MoIAttributes.tpp b/include/Attributes/MoIAttributes.tpp index 3026ed4..3faacc0 100644 --- a/include/Attributes/MoIAttributes.tpp +++ b/include/Attributes/MoIAttributes.tpp @@ -16,6 +16,8 @@ inline void MoIAttributes::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, const vector &thresholds) const { DEF_LOG ("MoIAttributes::cut", "thresholds:" << thresholds.size ()); + if (!thresholds.size ()) + return; double maxValue = CompAttribute::getMaxValue (); cerr << "moi max value:" << maxValue << endl; CompAttributeC::cut (allBands, attributeProfiles, 0, diff --git a/include/Attributes/SDAttributes.tpp b/include/Attributes/SDAttributes.tpp index 4d8ce99..180fe60 100644 --- a/include/Attributes/SDAttributes.tpp +++ b/include/Attributes/SDAttributes.tpp @@ -16,6 +16,8 @@ inline void SDAttributes::cut (vector > &allBands, const AttributeProfiles &attributeProfiles, const vector &thresholds) const { DEF_LOG ("SDAttributes::cut", "thresholds:" << thresholds.size ()); + if (!thresholds.size ()) + return; double maxValue = CompAttribute::getMaxValue (); cerr << "sd max value:" << maxValue << endl; CompAttributeC::cut (allBands, attributeProfiles, 0, diff --git a/src/Appli/Option.cpp b/src/Appli/Option.cpp index 60f9c6d..0e60ac9 100644 --- a/src/Appli/Option.cpp +++ b/src/Appli/Option.cpp @@ -191,8 +191,11 @@ Option::parse (int argc, char** argv) { GDALDataType inputType = inputImage.getDataType (); int bandInputCount = inputImage.getBandCount (); + if (selectedBand.empty ()) + selectedBand = Selected (0, bandInputCount-1); selectedBand.setLimits (0, bandInputCount-1); selectedBand.toSet (); + cerr << "coucou:" << selectedBand << endl; Size orgSize = inputImage.getSize (); if (width < 0 || width > orgSize.width) diff --git a/src/testMain.cpp b/src/testMain.cpp index 2c54a48..17edfef 100644 --- a/src/testMain.cpp +++ b/src/testMain.cpp @@ -51,7 +51,7 @@ void apGenerator (Option &option) { DimChanel maxThresholds = max (max (option.areaThresholds.size (), option.sdThresholds.size ()), option.moiThresholds.size ()); vector > allBands (maxThresholds, vector (leafCount, 0)); - DimChanel outputBandsCard = 1+treeTypesCard*(option.areaThresholds.size ()+option.sdThresholds.size ()+option.moiThresholds.size ()); // XXX * bands + DimChanel outputBandsCard = option.selectedBand.getSet ().size ()*(1+treeTypesCard*(option.areaThresholds.size ()+option.sdThresholds.size ()+option.moiThresholds.size ())); option.outputImage.createImage (option.size, option.inputImage.getDataType (), outputBandsCard); Raster raster; @@ -69,17 +69,18 @@ void apGenerator (Option &option) { 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 + if (option.areaThresholds.size ()) { + areaAttributes.cut (allBands, attributeProfiles, option.areaThresholds); + for (DimChanel c = 0; c < option.areaThresholds.size (); ++c, ++chanel) + option.outputImage.writeBand (&allBands[c][0], chanel); + } + if (option.sdThresholds.size ()) { 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 + if (option.moiThresholds.size ()) { XYAttributes xyAttributes (tree, areaAttributes); MoIAttributes moiAttributes (tree, areaAttributes, xyAttributes); moiAttributes.cut (allBands, attributeProfiles, option.moiThresholds); @@ -88,15 +89,6 @@ void apGenerator (Option &option) { } } } - //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"); cerr << endl << "*** apGenerator done!" << endl; }