Total Pageviews


September 30, 2015

Spot the Difference Using Image Subtraction

by 4hathacker  |  in Image Processing at  12:16 AM

In this session, we are going to study about next image arithmetic operation i.e., image subtraction.
It is also an easy operation like image addition. Consider the following function...

function image_sub()
a = imread('peppers.png');
figure; imshow(a); title('original image')
b = imadd(a,120);
figure; imshow(b); title('image addition')
c = imabsdiff(b,a);
figure; imshow(c); title('image subtraction')

The thing we are observing with image subtraction is practically seen. We are now getting the fact that it is using imabsdiff() function passing the two variables in which respected images are read using imread() function.

But what we are not getting behind the scenes is the utility of this operation. We studied and observed the utility of addition operation in increasing the brightness of an image. Similarly, we must also know the application of image subtraction.

Image subtraction is used to subtract the background variations in illuminations from a scene so that the foreground objects in it may be more easily analyzed.

To illustrate the usage of image subtraction we are going to discuss another example

Let us consider an image having 6 different shapes as rectangle, circle. a top left indentation page, hearts, a shape having corners cut and a cylinder along its length. Say it as an original image at t=t0 instant. Now due to some windy climate, the shape arrangements got a slight change in  their positions which cannot be seen with naked eyes at one's observation. And we got the image snap at t=t1 instant.

fig1. at t = t0

So, to observe the difference we have applied the image subtracttion arithmetic and made a function as described below.

fig2. at t = t2

function image_sub1()t
a = imread('C:\Users\lenovo\Desktop\fig1.png') ;
figure ; imshow(a); title('original image at t=t0')
b = imread('C:\Users\lenovo\Desktop\fig2.png') ;
figure ; imshow(b);title('original image at t=t1')
c = imabsdiff(a,b) ;
figure ; imshow(c);title('changes in image')
Sc = 255 - c ;
figure ; imshow(Sc);title('complementary image')

This function gives us the difference of the very minute shift of objects of different shapes between the time instant t1 and t0. And its complementary can be obtained in 'Sc' variable by subtracting it from 255.

Therefore, we can say that key application of image subtraction is in detecting the changes in a scene, an application used in target tracking and movement detection in surveillance applications.


Like Our Facebook Page

Nitin Sharma's DEV Profile
Proudly Designed by 4hathacker.