Subtracting Two Images using C# by asif

Basic Working Mechanism

I mentioned in my previous article on Image Subtraction about the basic phenomena of the nature about the mixture of colors. In its most straightforward implementation, this operator takes as input two identically sized images and produces as output a third image of the same size as the first two, in which the intensity of each pixel is the sum of the values of the corresponding pixels from each of the two input images. More sophisticated versions allow more than two images to be combined with a single operation.

A common variant of the operator simply allows a specified constant to be added to every pixel.

General Working

The subtraction of two images is performed straightforwardly in a single pass. The output pixel values are given by:

Q(x,y)=f(x,y)- h(x,y)

Or if it is simply desired to subtract a constant value C to a single image then:

Q(i,j)=P(i,j)- C

Where to Use Image Subtraction?

  • Image subtraction is widely used in the enhancement of the differences between images. This is the basic rule of Image Processing that the higher-order bit planes of an image carry a significant amount of visually relevant detail, while the lower planes contribute more to fine (often imperceptible) detail.
  • one of the most successful and beneficial uses of image subtraction is in the area of medical imaging called mask mode radiography. In this case h(x, y), the mask, is an X-ray image of a region of a patient’s body captured by an intensified TV camera (instead of traditional X-ray film) located opposite an X-ray source.The procedure consists of injecting a contrast medium into the patient’s bloodstream, taking a series of images of the same anatomical region as h(x, y), and subtracting this mask from the series of incoming images after injection of the contrast medium. The net effect of subtracting the mask from each sample in the incoming stream of TV images is that the areas that are different between f(x, y) and h(x, y) appear in the output image as enhanced detail. Because images can be captured at TV rates, this procedure in essence gives a movie showing how the contrast medium propagates through the vari?ous arteries in the area being observed.

Guidelines for Use

To understand the working of the Image Subtraction, take the example of the following images:

the Resultant Image Obtained by the subtraction of the above images is as:

Sample Project

Please Review other articles based on Logical Operators to get the better understanding of the project. The application seems to be in this GUI.

The project is a part of the series of the image processing articles written just for the prosperity and help for the students searching for Image Processing free stuff.


Project Files: