In this article, a few * variational image processing *techniques will be described along with application of those techniques with some images, most of the problems are taken from the assignments from this course.

## Some preliminaries: The Calculus of Images – Computing Curvature and TV

- Let’s first compute the
of a few images. The curvature measures the rate at which the unit gradient vector is changing and is given by*Euclidian Curvature* - The following couple of images are used to compute the curvature. As can be seen from the below figures, the curvature is zero in flat regions and along straight edges and non-zero along the rounded edges of the circles, as expected.
- Now, let’s compute the
, which is given by the following.*total variation (TV)* - First we need to approximate the
*partial derivatives*using a*forward difference*. - Let’s compute the
*TV*for the*grayscale image*Now let’s add more and more*Cameraman.*(by increasing the*Salt & Pepper noise**probability threshold p*) to the image and see how the norm of the gradient matrix along with the**TV**value changes from the following figure.

## The Heat Equation and Diffusion

Let’s implement the * isotropic *and

*by solving*

**anisotropic diffusion***numerically.*

**PDEs**The following figure shows the math.

The following shows the * isotropic diffusion* output with Δt = 0.1, with

*. As can be seen, the results are same as applying*

**gradient descent***on the image.*

**gaussian**blur kernelThe following shows the * anisotropic diffusion* output with Δt = 0.1, with

*with*

**gradient descent,***respectively. As can be seen, unlike isotropic diffusion, the anisotropic diffusion preserves the edges.*

**a = 5, 20, 100**## Creating Cartoon / flat-texture Images with Anisotropic Diffusion

As can be seen from the following figures and *animations*, we can create cartoons from the real images with * anisotropic diffusion*, by applying the diffusion on each channel, this time on color images (the

*barbara*image and

*my*image).

**Original image**

**Cartoon Image with anisotropic diffusion (a=5)**

**Original Image**

**Cartoon Image with anisotropic diffusion (a=5)**

## Total Variation Denoising

The following math is going to be used for * TV denoising*, the

*is used to solve the minimum of the*

**Euler-Lagrange equation***functional*, as shown in the following figures with

*.*

**proof**- First a
grayscale image is prepared by adding**noisy**to the**Gaussian noise**.**cameraman image**

**Original Cameraman**

**Noisy Cameraman**

- Let’s first
this image with**denoise**. The next animations show the results obtained , using the**linear****TV denoising***fidelity weight*. As can be seen, even with the fidelity term, this model blurs the edges.**λ=1**

- Now let’s
this image with**denoise**. The next animations show the results obtained , using the**Nonlinear****TV denoising***fidelity weight*and**λ=0.01**respectively.**λ=1**

## Image Inpainting

Inpainting is the process of ** restoring damaged** or

*parts of an image. Suppose we have a binary mask*

**missing***D*that specifies the location of the damaged pixels in the input image

*f*as shown below:

The following theory is going to be used for * TV inpainting*.

**Damaged image **

**Damaged image **

**Damaged image **

**Damaged image
**

Pingback: Sandipan Dey: Some more Variational Image Processing: Diffusion,TV denoising, Image Inpainting in Python | Adrian Tudor Web Designer and Programmer

Hi,

Nice post.

You better use Animated PNG (APNG) instead of GIF for better quality of your animations.

LikeLike

Thanks for the suggestion Royi

LikeLike

Pingback: Sandipan Dey: Some more Variational Image Processing: Diffusion, TV Denoising, TV Image Inpainting in Python | Adrian Tudor Web Designer and Programmer