Image Processing in MATLAB

MATLAB is a proprietary, closed-source software for image processing in robotic vision. It has a large built-in algorithms for image processing and computer vision, interactive interface between editor, variables and command line and can call external libraries like OpenCV. It is preferred by interdisciplinary researchers over other programming languages due to their domain-specific knowledge and experience with other MATLAB toolboxes for simulation, optimisation, statistics and data-science. There are no special instructions to initialise the environment in MATLAB. However, if you don’t have an Image Processing toolbox [1], install via Get-Add-Ons.

We read an image of a lorikeet, and convert the image into different colour space using the following snippet of code. While captured images are generally unsigned bit integers, it is important to convert them to floating numbers before performing mathematical operations. Once we convert these images into a double precision, the images lie in the range of [0, 1]. An RGB image composed of three colour channels can be converted into a single-channel grayscale image, CIE 1931 XYZ colour space, CIE 1976 L*a*b* colour space, YCbCr and more.

image = im2double(imread('images/lorikeet.png'));
imagesc(image)

imgycbcr = rgb2ycbcr(image);
imagesc(imgycbcr);

imggray = rgb2gray(image);
imagesc(imggray);
An image of Lorikeet in different colour spaces o RGB, YCbCr and Grayscale

We also perform multiple other mathematical operations on a 2D array to manipulate images [2]. This manipulation allows us to understand images, build stronger models with better generalisation, build algorithms that are scale-invariant and rotation-invariant which are common requirements in robotic vision. We can resize, rotate crop and flip images which can also add precise yet artistic effects in entertainment and photography domain.

image = im2double(imread('images/lorikeet.png'));

imgresized = imresize(image, 0.1);
imagesc(imgresized);

imgcropped = imcrop(image, [150 50 330 450]);
imagesc(imgcropped);

imgrotated = imrotate(image, 180);
imagesc(imgrotated);

imgflipped = flip(image, 2);
imagesc(imgflipped);

Each of these techniques is an in-built function that can be used by calling a line of code in MATLAB. It is, however, important to learn the underlying principles of each of these techniques, so we can interpret the outcome of such techniques to eliminate errors for precise robotic applications. For example, when we resize an image, we find new data points based on the existing discrete set of intensity values of an image and this is done by different kinds of interpolation techniques [3]. While MATLAB uses bicubic interpolation as a default version, we also have the ability to control the interpolation method as bilinear or nearest-neighbour with a desired shape of interpolation kernel. Another example is the use of flip techniques, where flipping in two dimensional can flip an image, but the same function can also be used to flip colour channels, which can be helpful for certain applications.

An image of Lorikeet at different image size
An image of Lorikeet (a) cropped (b) rotated and (c) flipped.

In robotic imaging, enhancement can be performed while capturing images, at a stage where we can manipulate the amount of photons we record in the sensor by exploiting imaging trade-offs. Regardless, we can additionally perform image enhancement digitally, modifying and manipulating the intensity and the order of image pixels. We can remove saturated pixels by adjusting the image contrast limit of an image, selecting only pixels of our preference threshold, equalising histogram to enhance contrast and even complementing pixels. In addition we can perform complex morphological operations, frequency domain filtering, convolution and correlations which are all useful in different aspects of robotic vision.

An image of Lorikeet (a) limits adjusted (b) pixels complemented and (c) histogram equalized.

These enhancement techniques are extremely useful for images with visual challenges. Robots that perform complex visual tasks such as delivery at night or driving in fog have very low contrast blending darker and lighter colour pixels, resulting in no precise features for mapping. In addition, industrial applications that are based on colour segmentation, object recognition and feature enhancement prefer immediate preliminary stages of image processing for robust performance. These techniques have a huge influence on understanding unknown images, like space.

Reference

  1. Image Processing Toolbox – MATLAB. 2022.
  2. Szeliski, R., 2010. Computer vision: algorithms and applications. Springer Science & Business Media.
  3. Resize image – MATLAB imresize – MathWorks Australia. 2022.
%d bloggers like this: