Skip to content

Commit 28970a0

Browse files
committed
unpublished adaptive manifold post
1 parent dc82423 commit 28970a0

File tree

5 files changed

+61
-45
lines changed

5 files changed

+61
-45
lines changed

_posts/XXXX-XX-XX-adaptive-manifolds.md

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,110 +3,112 @@ title: Adaptive Manifolds
33
tags: [computer vision, image processing, geometry, divulgation]
44
style: fill
55
color: danger
6-
description: A little know filtering technique.
6+
description: A little known filtering technique.
77
---
88

9-
![image](IMAGEN DE KEENAN)
9+
![image](./intro.png)
1010

1111
# Introduction
1212

13-
Manifolds: "variedades" in spanish. ¿Qué son los manifolds? Desde una perspectiva geométrica, son las **formas** que la geometría diferencial estudia. Estas formas se caracteŕizan, de manera intuitiva, por que si no acercamos conun zoom lo suficientemne grande, es decir, en la localidad, se ven como un espacio Euclídeo ordinario. Por ejemplo, si hablamos de la superficie de la Tierra (un esferoide), estamos hablando (aproximadamente) de un manifold, pues en ella, a un nivel humano (i.e. local), no es difícil discernir bajo inspección vaga si estamos viiendo en un plano o en una superficie con vurvatura. La asunciónd e los manifolds nos permite trasladar muchas de las herramientas del mundo Euclídeo 2D a espcaios curvos,.
13+
Manifolds: "variedades" in Spanish. What are manifolds? From a geometric perspective, they are the **shapes** that differential geometry studies. These shapes are intuitively characterized by the fact that if we zoom in sufficiently, that is, locally, they look like an ordinary Euclidean space. For example, if we talk about the surface of the Earth (a spheroid), we are (approximately) talking about a manifold, because at a human level (i.e., locally), it is not difficult to discern under vague inspection whether we are looking at a plane or a surface with curvature. The assumption of manifolds allows us to transfer many of the tools of the 2D Euclidean world to curved spaces.
1414

15-
COmo objeto matemático, los manifolds generalizan la noción de superficie curva en espacios de mayor dimensión; formalmente, se definen como espacios topológicos que localmente se parecen (en cierto sentido [1]) al espacio eculídeo R^n, pero globalmente puede tenre una estructura más compleja. UN manifold de dimensión n significa que localmente se comprta como R^n; por ejemplo,. uma linea (R¹) es un manifold 1D, una superficie como una esfera (R²) es un manifold 2D y el espacio en que vivimos (R³) es un maniofld 3D.
15+
As a mathematical object, manifolds generalize the notion of a curved surface in higher-dimensional spaces; formally, they are defined as topological spaces that locally resemble (in a certain sense [1]) Euclidean space \( R^n \), but globally they may have a more complex structure. An \( n \)-dimensional manifold means that locally it behaves like \( R^n \); for example, a line (\( R^1 \)) is a 1D manifold, a surface like a sphere (\( R^2 \)) is a 2D manifold, and the space we live in (\( R^3 \)) is a 3D manifold.
1616

17-
Pero, en el contecto del aprendizahje automático y procesamiento de señales, los manifolds se usan para represetnar datos en espacios de alta dimesión de menra eficiente. Por ejemplo., lo spíxeles de una imagen puieden estar distributidos en un manifold dentro de un espacio de características más grande, lo que permite aplicar para la técnica de filtrado que presentaremos a continuación.
17+
However, in the context of machine learning and signal processing, manifolds are used to efficiently represent data in high-dimensional spaces, as every "small regions" in the manifold can be mapped to a euclidean space. For example, the pixels of an image may be distributed in a manifold within a larger feature space, which enables the filtering technique we will present below.
18+
19+
In many machine learning problems, data resides on a manifold with a more complex structure than a conventional Euclidean space. For example, in biomechanics, joint movement follows geometric constraints that define a configuration space manifold. Similarly, in natural language processing, semantic relationships between words form curved spaces where distances are not linear but shaped by linguistic structure. Meshes, which represent 3D surfaces, and graphs, where distances are measured by edge traversal rather than straight lines, are also examples of non-Euclidean domains. Understanding the underlying geometry of these data structures enables more precise analysis and processing techniques.
20+
21+
The article in [3] presents a methodology for image mosaicing that overcomes the limitations of traditional methods, which use predetermined manifolds based on the type of camera motion. The proposal involves projecting strips of images onto manifolds adapted to the camera's movement, allowing mosaicing in more general situations, such as forward motion, overcoming the constraints of previous techniques. This post will build upon the work in [4], where they develop a high-dimensional image and video filtering technique in real-time, which accelerates the process by calculating the filter's response at a reduced set of points and then interpolating for all pixels. This approach allows the filtering cost to be linearly dependent on both the number of pixels and the dimension of the space in which the filter is applied. The technique is flexible, capable of approximating several types of standard filters, and even performing a hybrid Euclidean-geodesic filter in a single pass. Additionally, it is faster and requires less memory than previous methods, proving effective in tasks such as color filtering, noise reduction, and detail enhancement.
1822

1923
# Adaptive Manifold
2024

21-
Es archiconocido el hecho subyacente al párrafo anterior; las redes neuronales generan capas y capas de vectores de alta dimensión a partir de aplicar operaciones lineales y no lineales a los datos de entrada. EN este contexto, los datos pasan a ser representados en un sistema de coordenadas que mantiene una relación con el del espacio euclídeo original, pero que puede tener una estructura más compleja. Similarmente, los píxeles de una imagen no están distirbutidos de manera aleatoria, sino que tienden a organizarse en una estructura subyacente. Es posible entonces contruir un adaptive manifold de alta dimensión que funcione como una aproximación de la distribución de los píxeles en un espacio de (sus) caracteŕisticas.
25+
The underlying fact mentioned in the previous paragraph is well known; neural networks generate layers upon layers of high-dimensional vectors by applying linear and nonlinear operations to input data. In this context, data are represented in a coordinate system that maintains a relationship with the original Euclidean space but may have a more complex structure. Similarly, the pixels of an image are not randomly distributed but tend to organize themselves into an underlying structure. It is then possible to construct a high-dimensional adaptive manifold that approximates the distribution of pixels in a (sub)feature space.
2226

23-
El método Adaptive Manifolds explota esta estructura para realizar un filtrado eficiente, preservando detalles y bordes sin los altos costos computacionales de otros enfoques, como el filtro bilateral, que operan directamente ne el "espcio euclídeo" de los píxeles. A través de una jerarquía de aproximaciones adaptativas, este método permite suavizar la imagen de manera selectiva, respetando las transiciones de intensidad importantes.
27+
The Adaptive Manifolds method exploits this structure to perform efficient filtering, preserving details and edges without the high computational costs of other approaches, such as the bilateral filter, which operates directly in the "Euclidean space" of pixels. Through a hierarchy of adaptive approximations, this method allows selective smoothing of the image while respecting important intensity transitions.
2428

25-
## 1. **Construcción de la Variedad Adaptativa**
26-
Como la idea principal es representar una imagen \(u(\mathbf{x})\) en un manifold adaptativo \(\mathcal{M}\), la manera en que podemos hacer que el manifodl sea adaptativo es construirlo a través de una media ponderada (aproximación adaptativa) de la imagen:
29+
## 1. **Construction of the Adaptive Manifold**
30+
Since the main idea is to represent an image \( u(\mathbf{x}) \) on an adaptive manifold \( \mathcal{M} \), the way we can make the manifold adaptive is by constructing it through a weighted mean (adaptive approximation) of the image:
2731

2832
\[
2933
m(\mathbf{x}) = \frac{\int_{\Omega} G_s(\mathbf{x} - \mathbf{y}) I(\mathbf{y}) w(\mathbf{y}) d\mathbf{y}}{\int_{\Omega} G_s(\mathbf{x} - \mathbf{y}) w(\mathbf{y}) d\mathbf{y}}
3034
\]
3135

32-
Donde:
36+
Where:
3337

34-
- **\( I(\mathbf{x}) \)** es el valor de la imagen en el píxel **\( \mathbf{x} \)**.
35-
- **\( G_s(\mathbf{x} - \mathbf{y}) \)** es un filtro Gaussiano que suaviza la imagen en función de la distancia espacial entre los píxeles **\( \mathbf{x} \)** y **\( \mathbf{y} \)**. La desviación estándar **\( \sigma_s \)** controla el suavizado espacial.
36-
- **\( w(\mathbf{y}) \)** es una función de peso que controla la influencia de cada píxel **\( \mathbf{y} \)** en la aproximación.
37-
- **\( \Omega \)** es el dominio de la imagen.
38+
- **\( I(\mathbf{x}) \)** is the image value at pixel **\( \mathbf{x} \)**.
39+
- **\( G_s(\mathbf{x} - \mathbf{y}) \)** is a Gaussian filter that smooths the image based on the spatial distance between pixels **\( \mathbf{x} \)** and **\( \mathbf{y} \)**. The standard deviation **\( \sigma_s \)** controls spatial smoothing.
40+
- **\( w(\mathbf{y}) \)** is a weight function that controls the influence of each pixel **\( \mathbf{y} \)** in the approximation.
41+
- **\( \Omega \)** is the image domain.
3842

39-
Esta ecuación define una **media ponderada adaptativa** de la imagen, lo que permite que la imagen se suavice de manera que respete las transiciones de intensidad importantes, preservando bordes y detalles.
43+
This equation defines an **adaptive weighted mean** of the image, which allows the image to be smoothed in a way that respects important intensity transitions, preserving edges and details.
4044

41-
## 2. **División en Máscaras Adaptativas**
45+
## 2. **Segmentation into Adaptive Masks**
4246

43-
El siguiente paso en el filtro es dividir la imagen en dos regiones basadas en la comparación con la media adaptativa **\( m(\mathbf{x}) \)**. Esto se hace para permitir un tratamiento diferente de las áreas de la imagen según su relación con la intensidad media adaptativa.
47+
The next step in the filter is to divide the image into two regions based on comparison with the adaptive mean **\( m(\mathbf{x}) \)**. This is done to allow different treatment of image areas according to their relationship with the adaptive mean intensity.
4448

45-
- **Máscara Baja**: La región donde los valores de la imagen son menores o iguales a la media adaptativa \( m(\mathbf{x}) \):
49+
- **Low Mask**: The region where image values are less than or equal to the adaptive mean \( m(\mathbf{x}) \):
4650

4751
\[
48-
M_{\text{low}}(\mathbf{x}) = 1 \, \text{si} \, I(\mathbf{x}) \leq m(\mathbf{x})
52+
M_{\text{low}}(\mathbf{x}) = 1 \, \text{if} \, I(\mathbf{x}) \leq m(\mathbf{x})
4953
\]
5054

51-
- **Máscara Alta**: La región donde los valores de la imagen son mayores a la media adaptativa \( m(\mathbf{x}) \):
55+
- **High Mask**: The region where image values are greater than the adaptive mean \( m(\mathbf{x}) \):
5256

5357
\[
5458
M_{\text{high}}(\mathbf{x}) = 1 - M_{\text{low}}(\mathbf{x})
5559
\]
5660

57-
Esta segmentación permite tratar cada región de forma separada, lo que facilita la preservación de bordes en las transiciones de intensidad.
58-
61+
This segmentation allows each region to be treated separately, facilitating edge preservation in intensity transitions.
5962

60-
## 3. **Proyección en la Variedad Adaptativa**
63+
## 3. **Projection onto the Adaptive Manifold**
6164

62-
Una vez que la imagen se ha segmentado en las regiones baja y alta, cada punto de la imagen se proyecta en la variedad adaptativa utilizando un peso basado en la diferencia de intensidad entre el píxel actual **\( I(\mathbf{x}) \)** y la media adaptativa **\( m(\mathbf{x}) \)**:
65+
Once the image has been segmented into low and high regions, each point in the image is projected onto the adaptive manifold using a weight based on the intensity difference between the current pixel **\( I(\mathbf{x}) \)** and the adaptive mean **\( m(\mathbf{x}) \)**:
6366

6467
\[
6568
w(\mathbf{x}) = \exp \left( -\frac{(I(\mathbf{x}) - m(\mathbf{x}))^2}{\sigma_c^2} \right)
6669
\]
6770

68-
Donde **\( \sigma_c \)** controla la sensibilidad a las diferencias de intensidad.
71+
Where **\( \sigma_c \)** controls sensitivity to intensity differences.
6972

70-
El resultado es una convolución con el filtro Gaussiano \( G_s \):
73+
The result is a convolution with the Gaussian filter \( G_s \):
7174

7275
\[
7376
I'(\mathbf{x}) = \frac{\int_{\Omega} G_s(\mathbf{x} - \mathbf{y}) w(\mathbf{y}) I(\mathbf{y}) d\mathbf{y}}{\int_{\Omega} G_s(\mathbf{x} - \mathbf{y}) w(\mathbf{y}) d\mathbf{y}}
7477
\]
7578

76-
Esta ecuación realiza una **interpolación ponderada** sobre la variedad adaptativa, con el fin de suavizar la imagen sin perder detalles importantes.
79+
This equation performs a **weighted interpolation** on the adaptive manifold to smooth the image without losing important details.
7780

81+
## 4. **Recursive Filtering on the Manifold**
7882

79-
## 4. **Filtrado Recursivo sobre la Variedad**
80-
81-
Para mejorar la calidad del filtrado, se aplica de manera recursiva en múltiples niveles de profundidad **\( d \)**:
83+
To improve filtering quality, it is applied recursively at multiple depth levels **\( d \)**:
8284

8385
\[
8486
I_{d+1}(\mathbf{x}) = I_d(\mathbf{x}) + I_{\text{low}}(\mathbf{x}) + I_{\text{high}}(\mathbf{x})
8587
\]
8688

87-
Donde:
89+
Where:
8890

89-
- **\( I_{\text{low}}(\mathbf{x}) \)** y **\( I_{\text{high}}(\mathbf{x}) \)** son los componentes filtrados en cada nivel.
90-
- Se combinan los resultados de forma jerárquica.
91+
- **\( I_{\text{low}}(\mathbf{x}) \)** and **\( I_{\text{high}}(\mathbf{x}) \)** are the filtered components at each level.
92+
- The results are combined hierarchically.
9193

92-
Esta recursividad permite refinar el filtrado a medida que se realizan más iteraciones.
94+
This recursion allows refining the filtering as more iterations are performed.
9395

94-
## 5. **Comparación con el Filtro Bilateral**
96+
# Comparison with the Bilateral Filter
9597

96-
El filtro bilateral es otro método popular para suavizar imágenes mientras preserva los bordes. Sin embargo, el filtro bilateral es menos eficiente porque realiza el cálculo de la distancia en un espacio de mayor dimensión. La ecuación del filtro bilateral es la siguiente:
98+
The bilateral filter is another popular method for smoothing images while preserving edges. However, the bilateral filter is less efficient because it calculates distances in a higher-dimensional space. The bilateral filter equation is:
9799

98100
\[
99101
I'(\mathbf{x}) = \sum_{\mathbf{y} \in \Omega} G_s(\mathbf{x} - \mathbf{y}) G_c(I(\mathbf{x}) - I(\mathbf{y})) I(\mathbf{y}),
100102
\]
101103

102-
donde:
104+
where:
103105

104-
- **\( G_c \)** es un filtro Gaussiano en el dominio espacial que atenúa los píxeles que están más alejados entre sí.
105-
- **\( G_c \)** es un filtro Gaussiano en el dominio de intensidad, que suaviza las diferencias de intensidad.
106+
- **\( G_c \)** is a Gaussian filter in the spatial domain that attenuates pixels that are farther apart.
107+
- **\( G_c \)** is a Gaussian filter in the intensity domain, smoothing intensity differences.
106108

107-
La diferencia clave entre el filtro bilateral y el Adaptive Manifold Filter es que este último evita trabajar directamente en el espacio de alta dimensión de las intensidades de los píxeles. En cambio, utiliza una representación adaptativa de la imagen, lo que permite realizar el filtrado de manera más eficiente sin perder preservación de detalles y reduciendo los costos computacionales.
109+
The key difference between the bilateral filter and the Adaptive Manifold Filter is that the latter avoids working directly in the high-dimensional intensity space of pixels. Instead, it uses an adaptive representation of the image, enabling more efficient filtering while preserving details and reducing computational costs.
108110

109-
Para sigma_s=5.0, sigma_c=0.1, añadiendo ruido Gaussiano N(0,0.05) Y Poisson A LA IMAGEN ORIGINAl, estos son los resultados de PSNR y tiempo de ejecución:
111+
To maintain a common framework, we will use the same sigma values for both filters. For $\sigma_s=5.0$, $\sigma_c=0.1$, adding Gaussian noise $N(0,0.05)$ and Poisson noise to the original image, these are the results for PSNR and execution time:
110112

111113
![original](./orig.png)
112114

@@ -116,25 +118,39 @@ Para sigma_s=5.0, sigma_c=0.1, añadiendo ruido Gaussiano N(0,0.05) Y Poisson A
116118

117119
![bilat1](./bilat1.png)
118120

119-
Para sigma_s=7.0, sigma_c=0.25, añadiendo ruido Gaussiano N(0,0.25) Y Poisson:
121+
For $\sigma_s=7.0$, $\sigma_c=0.25$, adding Gaussian noise $N(0,0.25)$ and Poisson noise:
120122

121123
![noisy](./noisy.png)
122124

123125
![am](./am.png)
124126

125127
![bilat](./bilat.png)
126128

127-
Para sigma_s=5.0, sigma_c=0.5, añadiendo ruido Gaussiano N(0,0.25), Impulsional (p=0.02) Y Poisson:
129+
For $\sigma_s=5.0$, $\sigma_c=0.5$, adding Gaussian noise $N(0,0.25)$, Impulsive noise ($p=0.02$), and Poisson noise:
128130

129131
![noisy2](./noisy2.png)
130132

131133
![am2](./am2.png)
132134

133135
![bilat2](./bilat2.png)
134136

137+
We are fortunate that this filter is available in OpenCV (tested in C++); let’s try it out:
138+
139+
For $\sigma_s=16.0$, $\sigma_c=0.2$, adding Gaussian noise $N(0,0.25)$:
135140

136-
# Conclusión
141+
![noisy3](./noisy3.png)
137142

138-
Ante niveles altos de ruido, se nota una dominancia del método adaptive manifold sobre el bilateral, algo muy interesante. Ante niveles bajos, el biltro filateral puede filtrar mejor con kernels pequeños, pero si lo que se desea es eficiencia computacional, adaptive manifold es la opción a elegir.
143+
![am3](./am3.png)
144+
145+
![bilat3](./bilat3.png)
146+
147+
# Conclusion
148+
149+
At high noise levels, the adaptive manifold method shows superiority over the bilateral filter, which is quite interesting. At low levels, the bilateral filter may perform better with small kernels, but if computational efficiency is the goal, the adaptive manifold is the better choice.
139150

140151
[1] Keenan Crane, DISCRETE DIFFERENTIAL GEOMETRY: AN APPLIED INTRODUCTION, 2023 p. 9
152+
[2] Geometric Deep Learning Grids, Groups, Graphs, Geodesics, and Gauges Michael M. Bronstein1, Joan Bruna2, Taco Cohen3, Petar Veličković4 May 4, 2021
153+
[3] Peleg, S., Rousso, B., Rav-Acha, A., & Zomet, A. (2000). Mosaicing on adaptive manifolds.
154+
[4] Gastal, E. S. L., & Oliveira, M. M. (2012). Adaptive Manifolds for Real-Time High-Dimensional Filtering. ACM Transactions on Graphics (TOG), 31(4), 1–13.
155+
[5] OpenCV. Adaptive Manifold Filter Documentation. Retrieved from https://docs.opencv.org/3.4/de/db7/classcv_1_1ximgproc_1_1AdaptiveManifoldFilter.html
156+
1.19 MB
Loading
1.24 MB
Loading
13.4 KB
Loading
1.35 MB
Loading

0 commit comments

Comments
 (0)