fuzzyclust.image.local_similarity_image#
- fuzzyclust.image.local_similarity_image(img, lambda_s=3.0, lambda_g=6.0, window_size=3)[source]#
Locally adaptive weighted image of FGFCM, \(\xi_k=\sum_{r\in N_k}S_{kr}x_r/\sum_{r}S_{kr}\).
The similarity of pixel \(k\) and its neighbor \(r\) combines a spatial and a gray-level factor,
\[S_{kr}=S^{s}_{kr}\,S^{g}_{kr},\qquad S^{s}_{kr}=\exp\Big(-\frac{\max(|p_k-p_r|,|q_k-q_r|)}{\lambda_s}\Big),\qquad S^{g}_{kr}=\exp\Big(-\frac{\norm{\mathbf{x}_k-\mathbf{x}_r}^2}{\lambda_g\,\sigma_k^2}\Big),\]with \((p,q)\) the pixel coordinates and the local scale \(\sigma_k^2=\frac{1}{N_R}\sum_{r\in N_k}\norm{\mathbf{x}_r-\mathbf{x}_k}^2\), which makes the gray-level factor adapt to the local contrast (a neighbor that differs by more than the typical local difference gets a small weight – a noise pixel does not spoil its neighbors, and an edge is not blurred).