Sunday 3 October 2021

Denoising Drone Images with the ROF Algorithm in Python | For NDVI, UV a...



Consider Donating to Help the development of this project further:https://www.paypal.com/biz/fund?id=BLJ283JMTMT7S

Coding Used in This Video Here:https://github.com/MuonRay/Image_Denoising_with_ROF_algorithm

Removing noise from images is important for many applications, from making personal photos look better to improving the quality of satellite and increasingly drone images.

In image processing denoising functionally looks like we are smoothing out the image. But just what is it we are smoothing out to remove the noise? 

The ROF model has the interesting property that it finds a smoother version of the image while preserving edges and structures.

The underlying mathematics of the ROF model and the solution techniques are quite advanced and are showcased fully in the paper:

Nonlinear total variation based noise removal algorithms*
Leonid I. Rudin 1, Stanley Osher and Emad Fatemi 
Cognitech Inc., 2800, 28th Street, Suite 101, Santa Monica, CA 90405, USA. circa 1992. 

Its interesting to note that the authors base their work on work done previously by Geman and Reynolds in which they propse to minimise the non-linear functionals associated with noise in the total variance by use of simulated annealing, a metaheursitics technique, which would have been very slow to do using the computers available in the late 1980s something
which drove the development of the ROF denoising model in the first place.

The authors wanted a fast solver that could find a reasonably good local minima rather than the ideal global minima. 

Here I'll give a brief, simplified introduction before showing how to implement a ROF solver based on an algorithm by Chambolle.

The solver used in this code is a modified version that uses gradient descent/reprojection method to achieve total variance (TV) minimization/regularization

The integral of the gradient across an image, any image, will produce the total varience in the image. now, for noisy images the total varience will be higher. knowing this, denoising techniques have been developed that essentially minimise the total varience in the matrix element of an image and then reproject that image onto the original by subtracting
the imaginary form of the original image matrix element which contains the residual texture of the image. so textures are effectively removed when we want to do TV minimization/regularization.



To minimise the total varience in the matrix element different algorithms can be used but one of the most popular is gradient descent, which is similar to the simulated annealing technique originally proposed but more computationally tractable.


in gradient descent the image matrix containing the greyscale pixel values are essentially represented as an energy surface, whereby 
we want to descend into the global minima. the different values in the matrix represent the interaction energies of the nearest neighbor in this 2D energy surface. 
different algorithms can use
different equations to represent the interaction energies, depending on the rate at which
the interaction energies converge to a global minima in a certain steplength of 
iteration of the algorithm. 



Interesting Note: When implented using periodic boundary conditions the TV minimization using 
an iteractive gradient descent on an image performs 2 transformations on that
images rectangular image domain where the greyscale pixel values exist. 2 transformations 
on a rectangle result in the formation of a torus in a transformation which 
preserves the images pixel data but changes the domain topology. 
  
  
  
  
    An implementation of the Rudin-Osher-Fatemi (ROF) denoising model
    using the numerical procedure presented in equation 11 on pg 15 of
    A. Chambolle (2005)
    http://www.cmap.polytechnique.fr/preprint/repository/578.pdf