cpp:ps
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cpp:ps [2022/06/22 14:00] – francois | cpp:ps [2022/12/09 09:39] (current) – charles | ||
---|---|---|---|
Line 8: | Line 8: | ||
Dans cet exemple nous proposons de réaliser un pattern spectra à 2 dimensions. Cela signifie que la contribution de chaque nœud sera cumulé en fonction | Dans cet exemple nous proposons de réaliser un pattern spectra à 2 dimensions. Cela signifie que la contribution de chaque nœud sera cumulé en fonction | ||
* de la taille du nœud | * de la taille du nœud | ||
- | * et de sa caractéristique d' | + | * et de sa caractéristique d' |
===== Visualisation ===== | ===== Visualisation ===== | ||
Line 48: | Line 48: | ||
</ | </ | ||
- | En fonction de ce qui a été déclaré, il peut être utile de simplifier les appels en omettant le contexte d' | + | En fonction de ce qui a été déclaré, il peut être utile de simplifier les appels en omettant le contexte d' |
<code c++> | <code c++> | ||
using namespace std; | using namespace std; | ||
Line 59: | Line 59: | ||
Nous préfererons un histogramme logarithmique par défaut. | Nous préfererons un histogramme logarithmique par défaut. | ||
Nous choisissons un pattern spectra de 900 casses (30 bin x 30 bin). | Nous choisissons un pattern spectra de 900 casses (30 bin x 30 bin). | ||
- | La compression HDF5 à besoin de paramètres propres (taux de compression, | + | La compression HDF5 a besoin de paramètres propres (taux de compression, |
<code c++> | <code c++> | ||
typedef uint16_t DimBin; | typedef uint16_t DimBin; | ||
static const int GeoDimT (2); | static const int GeoDimT (2); | ||
- | static TreeType treeType = MAX; | + | static |
- | static DimBin linearCompactBin (false), linearAreaBin (false); | + | static |
- | static DimBin binCompactCount (30), binAreaCount (30); | + | static |
- | static unsigned int compressLevel (5); | + | static |
- | static size_t cacheSize (1024*1024); | + | static |
</ | </ | ||
Line 104: | Line 104: | ||
</ | </ | ||
- | Le point d'entré | + | Le point d'entrée |
* argv[0] : nom du programme | * argv[0] : nom du programme | ||
Line 121: | Line 121: | ||
</ | </ | ||
- | En fonction des pixels de l' | + | En fonction des pixels de l' |
<code c++> | <code c++> | ||
switch (inputImage.getDataType ()) { | switch (inputImage.getDataType ()) { | ||
Line 158: | Line 158: | ||
Raster< | Raster< | ||
// image size (width x height) | // image size (width x height) | ||
- | Size< | + | |
// read first band (0) in 2D mode from origine [0,0] to end [width, height]. | // read first band (0) in 2D mode from origine [0,0] to end [width, height]. | ||
inputImage.readBand (raster, 0, NullPoint2D, | inputImage.readBand (raster, 0, NullPoint2D, | ||
Line 167: | Line 167: | ||
cout << "Build tree" << endl; | cout << "Build tree" << endl; | ||
// no border (i.e. all pixels are take in account) | // no border (i.e. all pixels are take in account) | ||
- | Border< | + | |
// neighbors take in account (default connectivity C4) | // neighbors take in account (default connectivity C4) | ||
- | GraphWalker< | + | |
// tree builder base on raster, connectivity and type of tree | // tree builder base on raster, connectivity and type of tree | ||
ArrayTreeBuilder< | ArrayTreeBuilder< | ||
Line 192: | Line 192: | ||
// create area attribute | // create area attribute | ||
cout << "Build Area Attributes" | cout << "Build Area Attributes" | ||
- | AreaAttributes< | + | |
cout << "Build Perimeter Attributes" | cout << "Build Perimeter Attributes" | ||
- | PerimeterAttributes< | + | |
cout << "Build Compactness Attributes" | cout << "Build Compactness Attributes" | ||
- | CompactnessAttributes< | + | |
</ | </ | ||
- | Nous construisons des intervalles de valeurs (absices | + | Nous construisons des intervalles de valeurs (abscisses |
<code c++> | <code c++> | ||
cout << "Build PS" << endl; | cout << "Build PS" << endl; | ||
- | | + | |
- | vector< | + | |
linearSpace (0., 1., binCompactCount) : | linearSpace (0., 1., binCompactCount) : | ||
logSpace (1./ | logSpace (1./ | ||
- | vector< | + | |
linearSpace (1., MaxArea, binAreaCount) : | linearSpace (1., MaxArea, binAreaCount) : | ||
logSpace (1, MaxArea, binAreaCount); | logSpace (1, MaxArea, binAreaCount); | ||
</ | </ | ||
- | Nous le pattern spectra en parcourant tous les nœuds. | + | Nous calculons |
<code c++> | <code c++> | ||
vector< | vector< | ||
Line 220: | Line 220: | ||
for (DimParent compId = 0; compId < rootId; ++compId) { | for (DimParent compId = 0; compId < rootId; ++compId) { | ||
- | DimBin areaBinId = lower_bound (areaScale.begin (), areaScale.end (), double (areaValues[compId])) - areaScale.begin (); | + | |
- | DimBin compactBinId = lower_bound (compactScale.begin (), compactScale.end (), double (compactValues[compId])) - compactScale.begin (); | + | |
- | double diff = abs (double (weightValues[compId])- | + | |
- | double (weightValues[tree.getCompParent (compId)])); | + | double (weightValues[tree.getCompParent (compId)])); |
- | double volume = diff * areaValues[compId]; | + | |
- | size_t id (compactBinId + areaBinId * binCompactCount); | + | |
psTab [id] += volume; | psTab [id] += volume; | ||
} | } | ||
</ | </ | ||
- | Nous construisons, | + | Nous construisons, |
<code c++> | <code c++> | ||
vector< | vector< | ||
Line 279: | Line 279: | ||
</ | </ | ||
- | La commande '' | + | La commande '' |
<code bash> | <code bash> | ||
$ h5dump arles.kor | $ h5dump arles.kor | ||
Line 286: | Line 286: | ||
</ | </ | ||
- | Pattern Spectra | + | Le Pattern Spectra |
<code bash> | <code bash> | ||
| | ||
Line 299: | Line 299: | ||
</ | </ | ||
- | Abscisse | + | Voici les information permettant de reconstituer l'axe des abscisses. |
<code bash> | <code bash> | ||
| | ||
Line 324: | Line 324: | ||
</ | </ | ||
- | Ordonnée | + | Voici les information permettant de reconstituer l'axe des ordonnées. |
<code bash> | <code bash> | ||
| | ||
Line 348: | Line 348: | ||
} | } | ||
</ | </ | ||
- | Données réduites | + | |
+ | Pour l' | ||
<code bash> | <code bash> | ||
cpp/ps.1655906412.txt.gz · Last modified: 2022/06/22 14:00 by francois