You are on page 1of 8

Ex.

No:1

BASIC IMAGE PROCESSING WORKS

Date:
PROGRAM:

k=imread('e:\anush\raja.jpg');
imshow(k);
title('raja');
i=imfinfo('e:\anush\raja.jpg');
disp('PROPERTIES');
disp(i);
savefile = 'e:\anush\op2.mat';
save(savefile,'i');
imwrite(k,'e:\anush\newraja1.bmp');
m=imfinfo('e:\anush\newraja1.bmp');
savefile=('e:\anush\op4.mat');
save(savefile,'m');

Ex.No:2
TYPES

IMPLEMENTATION OF VARIOUS CLASSES &

Date:
PROGRAM:

%Class Conversion
close;
clear all;
k=imread('d:moon.tif');
l=im2uint16(k);
m=im2double(k);
n=im2uint8(m);
o=im2uint8(l);
whos;
%Type Conversion
R = imread('flowers.tif');
figure,imshow(R);
TITLE('Original Image');
%RGB to GRAY scale
G=rgb2gray(R);
figure,imshow(G);
title('RGB to GRAY');
%RGB to Binary
RB=im2bw(R,0.7);
figure,imshow(RB);
title('RGB to Binary');
%RGB to INDEXED
[I,map] = rgb2ind(R,256);
figure,imshow(I);
title('RGB to INDEXED');
%INDEXED to RGB
IR=ind2rgb(I,map);
figure,imshow(IR);
title('INDEXED to RGB');

%INDEXED to GRAY
IG=ind2gray(I,map);
figure,imshow(IG);
title('INDEXED to GRAY');
%INDEXED to BINARY
IB=im2bw(I,0.7);
figure,imshow(IB);
title('INDEXED to BINARY');
%GRAY TO BINARY
GB=im2bw(G,0.7);
figure,imshow(GB);
title('GRAY TO BINARY');
%GRAY TO INDEX
[GI,map]=gray2ind(G,256);
figure,imshow(GI,map);
title('GRAY TO INDEX');
%BINARY to INDEXED
[BI,map]=gray2ind(IB,256);
figure,imshow(BI,map);
title('BINARY to INDEXED');
%BINARY to GRAY
BG=ind2gray(BI,map);
figure,imshow(BG);
title('BINARY to GRAY');

Ex.No:4

HISTOGRAM PROCESSING

Date:
PROGRAM:

%HISTOGRAM OPERATION
clear;
close all;
i=imread('bacteria.tif');
subplot(1,2,1);
imshow(i);
title('Input Image');
subplot(1,2,2);
imhist(i);
title('Histogram for the given Image');
I = imread('pout.tif');
%Histogram Normalization
I1=im2double(I);
I1= (I1-min(I1(:)))/(max(I1(:))-min(I1(:)));
I2=im2uint8(I1);
figure;
subplot(2,2,1);
imshow(I);
title('Original Image');
subplot(2,2,2);
imshow(I2);
title('Noramlized Image');
subplot(2,2,3);
imhist(I);
title('Original Histogram');
subplot(2,2,4);
imhist(I2);
title('Normalized Histogram');
%HIstogram Equalisation
I3=histeq(I);
figure;
subplot(2,2,1);
imshow(I);

title('Original Image');
subplot(2,2,2);
imshow(I3);
title('Equalised Image');
subplot(2,2,3);
imhist(I);
title('Original Histogram');
subplot(2,2,4);
Imhist(I3);
title('Equalised Histogram');
%Histogram Matching
J=imread('d:\lena.bmp');
G=prod(size(J))/256;
H=G*ones(1,256);
match=histeq(I,H);
figure;
subplot(3,3,1);
imshow(I);
title('image1');
subplot(3,3,2);
imshow(J);
title('image2');
subplot(3,3,3);
imshow(match);
title('processed image');
subplot(3,3,4);
imhist(I);
title('histogram-1');
subplot(3,3,5);
imhist(J);
title('histogram-2');
subplot(3,3,6);
imhist(match);
title('matched histogram');

Ex.No:5

LINEAR & NON-LINEAR SPATIAL FILTERS

Date:

(Average Filter & Median Filter)

PROGRAM:

clear ;
close all;
%Average filters(Linear Filters);
i=checkerboard(1,20);
subplot(2,2,1);
imshow(i);
title('Original Image');
a = fspecial('average',2);
imaver = conv2(i,a);
subplot(2,2,2);
imshow(imaver);
title('Average filtering(Linear Filter)');
%Non-linear Filtering(Median filter)
I = imread('D:\lena.bmp');
J = imnoise(I,'salt & pepper',0.02);
K = medfilt2(J);
subplot(2,2,3);
imshow(J);
title('Before Filtering');
subplot(2,2,4);
imshow(K);
title('After median filtering(Non-Linear)')

Ex.No:3

BASIC SPATIAL DOMAIN TRANSFORMATIONS

Date:
PROGRAM:

close;
clear all;
I=imread('cameraman.tif');
for i=1:256
for j=1:256
I2(i,j)=256 -double(I(i,j));
I4(i,j)=60*log(1+double(I(i,j)));
I6(i,j)=25*power(double(I(i,j)),0.5);
end
end
I3=uint8(I2);
I5=uint8(I4);
I7=uint8(I6);
subplot(1,2,1);
imshow(I);
title('original image');
subplot(1,2,2);
imshow(I3);
title('IMAGE NEGATIVE');
figure,plot(I,I3);
title('Transformation Graph for IMAGE NEGATIVE');
figure,subplot(1,2,1);
imshow(I);
title('original image');
subplot(1,2,2);
imshow(I5);
title('log transformation');
figure,plot(I,I5);
title('Transformation Graph for LOG
TRANSFORMATION');

figure,subplot(1,2,1);
imshow(I);
title('original image');
subplot(1,2,2);
imshow(I7);
title('power-law transformation');
figure,plot(I,I7);
title('Transformation Graph for POWER-LAW
TRANSORMATION');

You might also like