Skip to content

Usuy-Leon/Filter-for-Multi-scale-Image-Decomposition

 
 

Repository files navigation

Multi=Scale image Decomposition

I forked this repo initially ment for MATLAB to write it again in python, Julia and with luck even make it a ImageJ extension. Is a very interesting Digital Filter. In short, It smooths an image while preserving strong edges.

  • If a region has low variance, it’s likely smooth (sky, wall, etc.), so it gets blurred more.

  • If a region has high variance (edges, textures), it’s likely important detail, so it’s preserved.


Sub-window Variance Filter

First descoription of this filter is in the article Multi-scale Image Decomposition Using a Local Statistical Edge Model. For details go check the paper.

Input Input Input
Input Per-pixel preservation (A) Filtered (result)

It decomposes an image into coarse (base), medium, and fine detail layers, then enhances those details using amplification factors.

Input
Both medium and fine details enhanced

Python Implementation

  1. Radius (r)

Think of it like blur size or scale of smoothing.

  1. Epsilon (e)

Defines the variance threshold to decide what is an "edge" versus a "flat area".

Parameter Symbol Meaning Effect
r (radius) Size of the local analysis window (in pixels). Controls how much area around each pixel is considered for variance estimation.
e (epsilon) Threshold variance defining what counts as an “edge.” Controls how strongly edges are preserved.

Workflow

Start simple:

Try the defaults: radius=3, epsilon=0.025, m_amp=2.0, f_amp=3.0.

Adjust smoothness:

Increase radius for more smoothing, decrease for sharper details.

Tune edge sensitivity:

  • If edges look too soft → decrease epsilon.
  • If too harsh or noisy → increase epsilon.

Control enhancement strength:

m_amp: affects edges and contrast.

f_amp: affects micro-textures. Start from 1.0 (neutral) and raise gradually.

Avoid artifacts:

  • Don’t set both amplifications too high (>4).

Julia Implementation

Key differences and improvements in the Julia version:

Performance benefits:
  • Julia's JIT compilation can make this code faster than the Python version
  • Better memory management and vectorization

To use this code:

using Pkg
Pkg.add(["Images", "ImageFiltering", "FileIO", "ArgParse"])

Run the script using bash:

julia svf_enhance.jl input_image.jpg --radius 3 --epsilon 0.025 --m_amp 2.0 --f_amp 3.0 --output enhanced.png

The Julia version maintains the same functionality while leveraging Julia's performance characteristics and type system.

About

Sub-window variance filter for Multi-scale Image Decomposition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.5%
  • Julia 45.5%