morphoTreeAdjust 0.1.8__tar.gz → 0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/CMakeLists.txt +1 -0
  2. morphotreeadjust-0.2/MANIFEST.in +3 -0
  3. {morphotreeadjust-0.1.8/morphoTreeAdjust.egg-info → morphotreeadjust-0.2}/PKG-INFO +14 -2
  4. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/README.md +1 -1
  5. morphotreeadjust-0.2/morphoTreeAdjust/include/AdjacencyRelation.hpp +147 -0
  6. morphotreeadjust-0.2/morphoTreeAdjust/include/Common.hpp +1065 -0
  7. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTree.hpp +778 -0
  8. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTree.tpp +834 -0
  9. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTreeAdjustment.hpp +440 -0
  10. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTreeAdjustmentByAnyNode.hpp +71 -0
  11. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTreeAdjustmentByFlatzone.hpp +64 -0
  12. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTreeAdjustmentByLeaf.hpp +64 -0
  13. morphotreeadjust-0.2/morphoTreeAdjust/include/ComponentTreeAdjustmentBySubtree.hpp +203 -0
  14. morphotreeadjust-0.2/morphoTreeAdjust/include/FlatZonesGraph.hpp +499 -0
  15. morphotreeadjust-0.2/morphoTreeAdjust/include/NodeCT.hpp +502 -0
  16. morphotreeadjust-0.2/morphoTreeAdjust/include/NodeCT.tpp +58 -0
  17. morphotreeadjust-0.2/morphoTreeAdjust/morphoTreeAdjust.cpp +216 -0
  18. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/morphoTreeAdjust/pybind/PyBindComponentTree.hpp +9 -6
  19. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTree.tpp +45 -0
  20. morphotreeadjust-0.1.8/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByLeaf.cpp → morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByAnyNode.cpp +8 -7
  21. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByAnyNode.hpp +35 -0
  22. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByFlatzone.cpp +25 -0
  23. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByFlatzone.hpp +35 -0
  24. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByLeaf.cpp +35 -0
  25. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentByLeaf.hpp +2 -2
  26. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentBySubtree.cpp +35 -0
  27. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentBySubtree.hpp +2 -2
  28. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindFlatZonesGraph.cpp +10 -0
  29. morphotreeadjust-0.2/morphoTreeAdjust/pybind/PyBindFlatZonesGraph.hpp +29 -0
  30. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/morphoTreeAdjust/src/AdjacencyRelation.cpp +69 -13
  31. morphotreeadjust-0.2/morphoTreeAdjust/src/ComponentTreeAdjustmentByAnyNode.cpp +40 -0
  32. morphotreeadjust-0.2/morphoTreeAdjust/src/ComponentTreeAdjustmentByFlatzone.cpp +172 -0
  33. morphotreeadjust-0.2/morphoTreeAdjust/src/ComponentTreeAdjustmentByLeaf.cpp +157 -0
  34. morphotreeadjust-0.2/morphoTreeAdjust/src/ComponentTreeAdjustmentBySubtree.cpp +250 -0
  35. morphotreeadjust-0.2/pyproject.toml +9 -0
  36. morphotreeadjust-0.2/python/morphoTreeAdjust/__init__.py +13 -0
  37. morphotreeadjust-0.2/python/morphoTreeAdjust/utils.py +280 -0
  38. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2/python/morphoTreeAdjust.egg-info}/PKG-INFO +14 -2
  39. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2/python}/morphoTreeAdjust.egg-info/SOURCES.txt +20 -6
  40. morphotreeadjust-0.2/python/morphoTreeAdjust.egg-info/requires.txt +4 -0
  41. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/setup.py +14 -8
  42. morphotreeadjust-0.1.8/MANIFEST.in +0 -2
  43. morphotreeadjust-0.1.8/morphoTreeAdjust/include/AdjacencyRelation.hpp +0 -72
  44. morphotreeadjust-0.1.8/morphoTreeAdjust/include/Common.hpp +0 -161
  45. morphotreeadjust-0.1.8/morphoTreeAdjust/include/ComponentTree.hpp +0 -111
  46. morphotreeadjust-0.1.8/morphoTreeAdjust/include/ComponentTree.tpp +0 -510
  47. morphotreeadjust-0.1.8/morphoTreeAdjust/include/ComponentTreeAdjustment.hpp +0 -200
  48. morphotreeadjust-0.1.8/morphoTreeAdjust/include/ComponentTreeAdjustmentByLeaf.hpp +0 -38
  49. morphotreeadjust-0.1.8/morphoTreeAdjust/include/ComponentTreeAdjustmentBySubtree.hpp +0 -146
  50. morphotreeadjust-0.1.8/morphoTreeAdjust/include/FlatZonesGraph.hpp +0 -581
  51. morphotreeadjust-0.1.8/morphoTreeAdjust/include/NodeCT.hpp +0 -604
  52. morphotreeadjust-0.1.8/morphoTreeAdjust/include/NodeCT.tpp +0 -279
  53. morphotreeadjust-0.1.8/morphoTreeAdjust/morphoTreeAdjust.cpp +0 -169
  54. morphotreeadjust-0.1.8/morphoTreeAdjust/pybind/PyBindComponentTree.tpp +0 -68
  55. morphotreeadjust-0.1.8/morphoTreeAdjust/pybind/PyBindComponentTreeAdjustmentBySubtree.cpp +0 -37
  56. morphotreeadjust-0.1.8/morphoTreeAdjust/src/ComponentTreeAdjustmentByLeaf.cpp +0 -193
  57. morphotreeadjust-0.1.8/morphoTreeAdjust/src/ComponentTreeAdjustmentBySubtree.cpp +0 -280
  58. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/LICENSE +0 -0
  59. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/morphoTreeAdjust/pybind/PybindUtils.hpp +0 -0
  60. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/pybind11.cmake +0 -0
  61. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2/python}/morphoTreeAdjust.egg-info/dependency_links.txt +0 -0
  62. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2/python}/morphoTreeAdjust.egg-info/not-zip-safe +0 -0
  63. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2/python}/morphoTreeAdjust.egg-info/top_level.txt +0 -0
  64. {morphotreeadjust-0.1.8 → morphotreeadjust-0.2}/setup.cfg +0 -0
@@ -9,6 +9,7 @@ project(MorphoTreeAdjust LANGUAGES CXX)
9
9
  set(CMAKE_CXX_STANDARD 20)
10
10
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
11
11
  set(CMAKE_CXX_EXTENSIONS OFF)
12
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
12
13
 
13
14
  # Define build padrão, se não for especificado
14
15
  if(NOT CMAKE_BUILD_TYPE)
@@ -0,0 +1,3 @@
1
+ include README.md LICENSE CMakeLists.txt pybind11.cmake
2
+ recursive-include morphoTreeAdjust *.cpp *.hpp *.tpp
3
+ recursive-include python *.py
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: morphoTreeAdjust
3
- Version: 0.1.8
3
+ Version: 0.2
4
4
  Summary: MorphoTreeAdjust is a C++/Python implementation for adjusting the morpholofical trees.
5
5
  Home-page: https://github.com/wonderalexandre/ComponentTreeLearn
6
6
  Author: Wonder Alexandre Luz Alves
@@ -13,3 +13,15 @@ Classifier: Topic :: Scientific/Engineering :: Image Processing
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: C++
15
15
  License-File: LICENSE
16
+ Provides-Extra: viz
17
+ Requires-Dist: numpy; extra == "viz"
18
+ Requires-Dist: matplotlib; extra == "viz"
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: home-page
23
+ Dynamic: keywords
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: provides-extra
27
+ Dynamic: summary
@@ -16,4 +16,4 @@ Problem:
16
16
  > [Click here and see a demo on jupyter notebook](./notebooks/morphoTreeAdjust_example_leaf.ipynb)
17
17
 
18
18
  ### Paper:
19
- > Alves, W. A. L., Passat, N., Silva, D. J., Morimitsu, A., & Hashimoto, R. F. (2025). *Efficient connected alternating sequential filters based on component trees*. Paper submitted to the 4th International Conference on Discrete Geometry and Mathematical Morphology (DGMM 2025).
19
+ > Wonder Alves, Nicolas Passat, Dênnis José da Silva, Alexandre Morimitsu, Ronaldo F. Hashimoto. *Efficient connected alternating sequential filters based on component trees*. International Conference on Discrete Geometry and Mathematical Morphology (DGMM), Nov 2025, Groningen, Netherlands. ⟨[hal-05163556](https://hal.science/hal-05163556/)
@@ -0,0 +1,147 @@
1
+
2
+ #include <list>
3
+ #include <vector>
4
+ #include "../include/Common.hpp"
5
+
6
+ #ifndef ADJACENCY_H
7
+ #define ADJACENCY_H
8
+
9
+ class AdjacencyRelation; // forward declaration
10
+ using AdjacencyRelationPtr = std::shared_ptr<AdjacencyRelation>;
11
+
12
+ /**
13
+ * @brief Relação de adjacência em grade 2D com raio arbitrário e iteração eficiente.
14
+ *
15
+ * Define offsets de vizinhança para uma janela de raio real (ex.: 1.0 → 4-adj, 1.5 → 8-adj),
16
+ * provendo utilitários para listar vizinhos de um pixel e iterar por eles com um iterador leve.
17
+ * Também oferece uma variação "forward" que emite somente metade dos vizinhos (sem simetria),
18
+ * útil para varreduras assimétricas e construção de arestas únicas.
19
+ */
20
+ class AdjacencyRelation {
21
+ private:
22
+ int id;
23
+
24
+ int row;
25
+ int col;
26
+ int numCols;
27
+ int numRows;
28
+ double radius;
29
+ double radius2;
30
+ int n;
31
+ bool forwardOnly = false; //meia
32
+
33
+ std::vector<int> offsetRow;
34
+ std::vector<int> offsetCol;
35
+ std::vector<uint8_t> forwardMask;// máscara “forward” por offset i: true se (dy>0) || (dy==0 && dx>0)
36
+
37
+
38
+ public:
39
+ /**
40
+ * @brief Constrói uma relação de adjacência para imagem `numRows`×`numCols`.
41
+ * @param numRows Número de linhas da imagem.
42
+ * @param numCols Número de colunas da imagem.
43
+ * @param radius Raio da vizinhança (1.0 ≈ 4-conexão, 1.5 ≈ 8-conexão).
44
+ */
45
+ AdjacencyRelation(int numRows, int numCols, double radius);
46
+ /**
47
+ * @brief Avança para o próximo offset válido conforme os limites e máscara.
48
+ * @return Índice do próximo offset válido, ou tamanho para fim.
49
+ */
50
+ int nextValid();
51
+ /**
52
+ * @brief Retorna a quantidade de offsets no stencil atual.
53
+ */
54
+ int getSize();
55
+ /**
56
+ * @brief Configura (row,col) e prepara iteração de adjacentes sem filtro forward. Esse método incluí a origem.
57
+ */
58
+ AdjacencyRelation& getAdjPixels(int row, int col);
59
+ /**
60
+ * @brief Configura por índice linear e prepara iteração de adjacentes sem filtro. Esse método incluí a origem.
61
+ */
62
+ AdjacencyRelation& getAdjPixels(int index);
63
+ /**
64
+ * @brief Configura (row,col) e prepara iteração de vizinhos dentro dos limites. Esse método NÃO incluí a origem.
65
+ */
66
+ AdjacencyRelation& getNeighborPixels(int row, int col);
67
+ /**
68
+ * @brief Configura por índice linear e prepara iteração de vizinhos dentro dos limites. Esse método NÃO incluí a origem.
69
+ */
70
+ AdjacencyRelation& getNeighborPixels(int index);
71
+ /**
72
+ * @brief Prepara iteração apenas sobre metade dos vizinhos (forward-only) em (row,col).
73
+ * @note Útil para gerar pares (p,q) sem duplicação (p→q, nunca q→p).
74
+ */
75
+ AdjacencyRelation& getNeighborPixelsForward(int row, int col);
76
+ /**
77
+ * @brief Versão por índice linear de `getNeighborPixelsForward`.
78
+ */
79
+ AdjacencyRelation& getNeighborPixelsForward(int index);
80
+
81
+ /**
82
+ * @brief Verifica adjacência por índices lineares (p,q).
83
+ */
84
+ inline bool isAdjacent(int p, int q)const noexcept;
85
+ /**
86
+ * @brief Verifica adjacência por coordenadas (px,py) e (qx,qy).
87
+ */
88
+ inline bool isAdjacent(int px, int py, int qx, int qy) const noexcept;
89
+ /**
90
+ * @brief Retorna o raio em uso.
91
+ */
92
+ double getRadius();
93
+
94
+ int getOffsetRow(int index){
95
+ return offsetRow[index];
96
+ }
97
+ int getOffsetCol(int index){
98
+ return offsetCol[index];
99
+ }
100
+
101
+ /**
102
+ * @brief Iterador leve para percorrer vizinhos já configurados via `get*`.
103
+ *
104
+ * Produz índices lineares de pixels vizinhos válidos, respeitando os limites e,
105
+ * quando configurado, a máscara forward-only.
106
+ */
107
+ class IteratorAdjacency {
108
+ private:
109
+ int index;
110
+ AdjacencyRelation* instance;
111
+
112
+ public:
113
+ using iterator_category = std::input_iterator_tag;
114
+ using value_type = int;
115
+
116
+ IteratorAdjacency(AdjacencyRelation* obj, int id) : index(id), instance(obj) { }
117
+
118
+ AdjacencyRelation* getInstance() { return instance; }
119
+
120
+ IteratorAdjacency& operator++() {
121
+ this->index = instance->nextValid();
122
+ return *this;
123
+ }
124
+
125
+ bool operator==(const IteratorAdjacency& other) const {
126
+ return index == other.index;
127
+ }
128
+ bool operator!=(const IteratorAdjacency& other) const {
129
+ return !(*this == other);
130
+ }
131
+
132
+ int operator*() const {
133
+ return (instance->row + instance->offsetRow[index]) * instance->numCols + (instance->col + instance->offsetCol[index]);
134
+ }
135
+ };
136
+ /**
137
+ * @brief Início da iteração de vizinhos conforme configuração atual.
138
+ */
139
+ IteratorAdjacency begin();
140
+ /**
141
+ * @brief Marcador de fim da iteração de vizinhos.
142
+ */
143
+ IteratorAdjacency end();
144
+ };
145
+
146
+
147
+ #endif