Image Processing and Filtering Techniques

written by Anar Rzayev

XBrain Info
XBrain
4 min readSep 8, 2021

--

Recently I visited the Dongdaemun History Museum in the city of Seoul, not very far from the World cup stadium in Mapo-gu. While visiting the famous exhibitions, we all got a chance to look around the museum. It’s a nice little place with several quirky old machines on display, some dating back to the 19th century. Hanging on a wall in a dimly lit corner of the museum was a framed copy of an engineer’s decadic logarithm (and anti-logarithm) tables.

Figure 1: Logarithmic table for use with calculating machine

A friend of mine who was visiting around with me commented, “Ah, logs…haven’t seen these since school days.” That got me thinking. When was the last time I used logarithms? Well, just in the last week, I had used the log function for scaling the Fourier magnitude spectrum of an image for better visualization. It took me a moment though to make the mental connection between the printed log tables and the log’s functional form, but as soon as I did, I realized that I used the log quite often during my internship at XBrain Team.

One of the problems we faced while working on the task of detecting color features using state-of-art deep learning models was light tuning. The direction and intensity of light exposure vary so much depending on the image, thus we, ML (Machine Learning) team, felt the need to normalize the light exposed to the image. There are multiple famous research papers written about shiny light tuning, and one of the methods implemented to remove multiplicative noise is a homomorphic filter.

This filter is responsible for removing the shiny light background from the image. Homomorphic filtering is most commonly used for correcting non-uniform illumination in images. The illumination-reflectance model of image formation says that the intensity at any pixel, which is the amount of light reflected by a point on the object, is represented as a product of illumination and reflectance:

where I is the image, L is scene illumination and R is the scene reflectance.

Illumination is assumed to be slowly varying and the main contributor of dynamic range. This is essentially low-frequency content. Reflectance represents details of objects and is assumed to vary rapidly. This is also the primary contributor to local contrast and is essentially high-frequency content.

The image can be represented as a product of these two. Homomorphic filtering tries and splits up these components and we filter them individually. We then combine the results together when we are finished. As this is a multiplicative model, it’s customary to use a log operation so that we can express the product as a sum of two terms.

Then we use a high-pass filter in the log domain to remove the low-frequency illumination component while preserving the high-frequency reflectance component. These two terms are filtered individually, scaled to emphasize or de-emphasize their contributions to the image, summed, then the anti-log is taken.

The basic steps in homomorphic filtering are shown in the diagram below:

Figure 2: Frequency domain high-filter

The shading is due to the illumination, and so what we can do is decrease the contribution that this shading does over the image. We can also boost the reflectance so we can get some better edges as edges are associated with high-frequency information.

Figure 3: Application of homomorphic filtering with Gaussian sigma = 10

We usually filter the illumination using a low-pass filter, while the reflectance with a high-pass filter. In this case, it was decided to choose a gaussian sigma of 10 as the low-pass filter. A high-pass filter can be obtained by taking 1 and subtracting it with the low-pass filter. After transforming the image into the log domain, the next step is to filter the image in the frequency domain using the low-pass and high-pass filters. We then scale the low pass and high pass results, add these components back, then take the anti-log. This image is now better suited to be thresholded as the image has low variation.

Figure 4: Implementation of image filtering and comparisons between original and homomorphic

--

--