Multiplication of images


Mathematical operations on digital images consist of:
1. Addition
2. Subtraction
3. Multiplication
4. Division

Arithmetic multiplication:
Arithmetic subtraction can be done using the following two ways:
1. Pixel to pixel multiplication of two images
2. Multiplication of a constant to an image

Pixel to pixel multiplication of two images
This is the most simple and straightforward operation applied on two input images of identical dimensions that produces an output image of dimensions identical to that of first two, in which a pixel value of the output image is the arithmetic multiplication of the corresponding pixels from the two input images. Mathematically, the multiplication operation of two images can be written as:
m(x,y)=f(x,y)*g(x,y)
Where
f and g are the two input images of identical dimensions and m is the resulting output image while x and y are the spatial coordinates of the corresponding input and output images.

If the pixel values in the input image are vectors (e.g. for color images) then the individual components of each of the three channels (i.e., red, green and blue) are multiplied separately from the corresponding input images to produce the output value. More often to reduce the computational time and complexity, programmers prefer to use grayscale images.

Apparently, the resulting output shall depend on the image format of the input images used. For example, if the two input grayscale images are of uint8 class, the output grayscale image will have pixel values within the dynamic range [0, 255] i.e., if the pixel multiplication of the corresponding two pixels overflows above the maximum value of the dynamic range of the image, the output image will have pixel value equal to the maximum pixel value. Hence, increasing the dynamic range of the image is recommended. For more information on class and their dynamic range click here.

Multiplication of constant from an image
Alternatively, another popular variant in image multiplication allows the multiplication of a constant to every pixel of the input image. Mathematically, the multiplication of a constant to an image pixel can be expressed as:
m(x,y) = f(x,y) * c
Where f is the input image, c is the constant and m is the resulting output image while x and y are the spatial coordinates of the input and output images. 

Octave code:
Multiplication operation on image
clc;
clear all;
close all;
f = imread("full-moon.jpg");
[h1 w1 c1] = size(f);
if c1 == 3
  f = rgb2gray(f);
end
figure, imshow(f); title("Input grayscale image");
p = immultiply(f,f,"uint16");
figure, imshow(p); title("Result of multiplication operation");

Output:
Input grayscale image
Result of multiplication operation






Comments

Popular posts from this blog

Washing Machine: An example of mechatronics system

Proximity sensors

Piezoelectric Pressure Sensor