Sunday, 11 September 2016

Program for Negative of Image Using Matlab

 Program for Negative of Image Using Matlab

A negative image is a total inversion, in which light areas appear dark and vice versa.
In negative transformation, each value of the input image is subtracted from the L-1 and mapped onto the output image.In this case the following transition has been done.
s = (L – 1) – r
Assuming the input image be 8 bit image , so the number of levels in this image are 256. Putting 256 in the equation, we get this,
s = 255 – r
So each value is subtracted by 255 and the result image has been shown above. So what happens is that , the lighter pixels become dark and the darker picture becomes light. And it results in image negative.
 

Program for Negative of Image 

clc;
clear all;
a=imread('D:\sample.jpg');
b=rgb2gray(a);
c=double (b);
d=255;                           % for a 8-bit image %
e=d-c;
figure(1)
colormap(gray)
imagesc(b)
title('Original Image')
figure(2)
colormap(gray)
imagesc(e)
title('Negative Image')



OUTPUT:

No comments:

Post a Comment