Real Estate Image Quality Enhancement

This article discusses the techniques that we can use to increase the quality of the digital images.

Prateek Chhikara
Engineering @ Housing/Proptiger/Makaan
6 min readMar 28, 2022

--

Cover Art

What Does Image Enhancement Mean?

Image enhancement refers to emphasizing certain information in an image and weakening or discarding any unneeded information according to specific needs. In simpler words, Image enhancement is a process of enhancing (or improving) the image for better analysis. For instance, eliminating noise, revealing blurred details, and adjusting levels to highlight features of an image.

Following are the widely handled use-cases for image enhancement.

  1. Sharpness
  2. Brightness
  3. De-noising
  4. Contrast
  5. Super Resolution

This article will demonstrate each of the mentioned use-cases using real-estate images and code snippets.

1. Sharpness

The sharpness of a digital image refers to the clarity or detail in an image and can be a valuable creative tool for emphasizing texture. Proper photographic and post-processing techniques can go a long way towards improving sharpness, although sharpness is majorly limited by camera equipment, image magnification and viewing distance. Blur has a relation with the sharpness; for instance, if there is more blur in an image, it means the image is less sharp.

There are several methods or libraries which increases the sharpness of an image. In this article, we will discuss the sharpness method implemented in the Wand library of Python [1]. The sharpen() function is an inbuilt function in the Python Wand ImageMagick library which is used to sharpen the image.

from wand.image import Image
img = Image(filename)
img.sharpen(radius, sigma)

Parameters: This function accepts two parameters:
radius: size of gaussian aperture.
sigma: standard deviation of the gaussian filter.

Return Value: This function returns the Wand ImageMagick object.

Example:

Selected Parameters: radius = 8 and sigma = 4.

Figure 1. Results of Wand Sharpen method on a blur image.

2. Brightness

Brightness is a measure of intensity of all the pixels that constitutes the digital image after being captured, digitized, and displayed. Pixel brightness is an essential aspect in digital images because (other than colour) it is the only variable that can be utilized by processing techniques to adjust the image quantitatively.

Brightness can be controlled by increasing or decreasing the pixel values; increasing the pixel values closer to 255 will make the pixel white, and if we make it closer to 0, the pixel will become black.

It is intricate to find the amount by which we should increase or decrease the pixel values because brightness is image dependent. We can not state that an image with an average pixel value close to 125 is excellent, while one with 95 is terrible. Therefore, researchers have proposed many algorithms to solve this problem.

Example: We have used algorithm implemented by Ying et al. [2][3].

Figure 2. Brightness enhancement of a dark image using Ying et al. approach.

3. De-noising

Noise is a random variation of brightness or colour information in images and an undesirable by-product of the image that obscures the desired information. Therefore, Image denoising techniques are used for removing noise from a noisy image to restore the actual appearance. Noise can be Gaussian, Salt & Pepper, Poisson, Speckle, etc.

There are many ways we can reduce the noise in an image such as using mean filters, median filters, etc. However, there are two widely used techniques that solves this issue which are Bilateral Filter and fast Non local Means.

Example:

# Bilateral Filterimport cv2
img = cv2.imread(img)
output_image1 = cv2.bilateralFilter(img, d, sigmaColor, sigmaSpace)

Parameters:
d:Diameter of each pixel neighborhood.
sigmaColor: Value of sigma in color space.
sigmaSpace: Value of sigma in coordinate space.

Return Value: This function returns the numpy object.

# fast Non local Meansimport cv2
img = cv2.imread(img)
output_image2 = cv2.fastNlMeansDenoisingColored(img, a, b, c, d, e)

Parameters:
a: Destination Image Array.
b: Size in pixels of the template patch that is used to compute weights.
c: Size in pixels of the window that is used to compute a weighted average for the given pixel.
d:
Parameter regulating filter strength for luminance component.
e:
Parameter regulating filter strength for luminance component.

Return Value: This function returns the numpy object.

Example:

Selected Parameters:
Bilateral Filter: d = 75, sigmaColor = 32, and sigmaSpace = 32
Fast NLMeans: a = None, b = 7, c = 7, d = 5, and e = 21

Figure 3. Removal of noise by using bilateral filter and fast NL means algorithms.

Fast NL Means perform better when compared to bilateral filter because there is information loss in the case of bilateral filter.

4. Contrast

Contrast is the difference in luminance or colour that makes an object distinguishable from other objects within the same field of view. A real-life example can better explain it; consider a scenario of a sunny and a foggy day. On a sunny day, everything looks clear to us, thus having a high contrast compared to a foggy day, where everything looks almost the same intensity (dull, washed-out grey look).

There are several image processing approaches to enhance contrast: histogram equalization (HE), adaptive histogram equalization (AHE), and contrast limited AHE (CLAHE). While experimenting, CLAHE outperforms the rest in terms of overall quality and details.

import cv2image = cv2.imread(filepath)
im = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
h, s, v = cv2.split(im)
clahe = cv2.createCLAHE(clipLimit, tileGridSize)
v = clahe.apply(v)
im = cv2.merge((h,s,v))
output_image = cv2.cvtColor(im, cv2.COLOR_HSV2RGB)

Parameters: This function accepts two parameters:
clipLimit: This parameter sets the threshold for contrast limiting.
tileGridSize: This sets the number of tiles in the row and column.

Return Value: This function returns the numpy object.

Example:

Selected Parameters: clipLimit = 0.8 and tileGridSize = (4, 4).

Figure 4. Contrast enhancement using CLAHE on an image with less contrast.

The original image is on the brighter side, having less information. However, the enhanced part has some shadows, which provides more detail and a rich pixel range.

5. Super Resolution

Super-resolution is a technique that converts a low-resolution image of a scene to a high-resolution image. In essence, this method adds more information to the images because the more the pixels are in an image, the higher information or details it possesses.

Super Resolution is mainly taken care of by Deep Learning approaches because of their excellent results, which beats traditional techniques such as Nearest Neighbor Interpolation or Bilinear Interpolation. Deep Learning approaches that are widely used to solve this use-case are as follows.
1. Pre-Upsampling Super Resolution
2. Post-Upsampling Super Resolution
3. Recursive Networks
4. Attention-Based Networks
5. Generative Models

Example: We have used the EDSR model proposed by Lim et al. [4][5].

Figure 5. Super-resolution performed on a small resolution image using EDSR.

Conclusion

This article demonstrated the different aspects (such as sharpness, brightness, de-noise, contrast, and super resolution) in which we can enhance the overall quality of an image. Further, appraoches were discussed which can solve such issues with a code snippet or some open source tools. The readers can play with the parameters and can find the best parameters for their use-case.

--

--

Prateek Chhikara
Engineering @ Housing/Proptiger/Makaan

AI Engineer @ Autoenhance.ai | CS @ University of Southern California | 3+ years of industrial experience. Website: https://www.prateekchhikara.com