+ All Categories
Home > Engineering > project file for digital image processing for B.tech students

project file for digital image processing for B.tech students

Date post: 15-Jul-2015
Category:
Upload: vasundhara-ghose
View: 226 times
Download: 9 times
Share this document with a friend
Popular Tags:
15
1 Program No-1 Implement the spatial image enhancement functions on a bitmap image – Rotation(clockwise). Program- I = fitstread(‘solarspectra.fts’); I = mat2gray(I); J = imrotate(I,-10,’bilinear’,’crop’); Imshow(I) Figure,imshow(j) Output:- Fig: Original Image Fig: Rotated Image
Transcript

1

Program No-1

Implement the spatial image enhancement functions on a bitmap image –

Rotation(clockwise).

Program-

I = fitstread(‘solarspectra.fts’);

I = mat2gray(I); J = imrotate(I,-10,’bilinear’,’crop’);

Imshow(I) Figure,imshow(j)

Output:-

Fig: Original Image Fig: Rotated Image

2

Program No-2

Aim:- Implement the spatial image enhancement functions on a bitmap image-Enlargement (Double Size).

Program-

I=imread(‘circuit.tif’);

J=imresize(I,2.0); Imshow(I)

Figure,imshow(J) Output:-

Fig:original image

Fig: Enlarged Image

3

Program No-3

Aim- To apply Laplacian Transform on image

Program-

f=imread(‘moon.tif’); w4=fspecial(‘laplacian’,0); w8=[1 1 1;1 -8 1;1 1 1];

f=im2double(f); g4=f-imfilter (f,w4,’replicate’); g8=f-imfilter (f,w4,’replicate’);

imview(f) figure,imview(g4) figure,imview(g8)

Output:

Fig:Original image Fig:image after laplacian transformation

4

Fig:Image after second laplacian transformation

5

Program No-4

Write a M-File function to provide NEGATIVE transformation (Basic

gray-level transformations.)

function [y]=negative(varargin) a=varargin{1}; [m n]=size(a);

for i=1:1:m for j=1:1:n

b=a(i,j); c=255-b; a(i,j)=c;

end end

mat2gray(a) y=a

Output:

a=imread('cam.bmp')

imshow(a) b=negative(a) ; imshow(b);

6

Program No-5

Write a M-File function to provide LOG transformation (Basic gray-level transformations.)

function [y]=logtran(varargin)

aa=varargin{1}; [m n]=size(aa); z=varargin{2};

a=im2double(aa); for i=1:1:m for j=1:1:n

b=a(i,j); c=z*log(1+b);

a(i,j)=c; end end y=a

Output:

a=imread('cam.bmp')

imshow(a) b=logtran(a,2)

imshow(b) b=logtran(a,5)

imshow(b)

7

Fig:Image after LOG transformation

Fig: Original Image

8

Program No-6

Write a M-File function to provide POWER LAW transformation (Basic gray-level transformations.)

function [y]=powerlaw(varargin)

aa=varargin{1}; [m n]=size(aa); z=varargin{2};

a=im2double(aa); aa=a.^z

mat2gray(aa) y=aa

Output:

a=imread('cam.bmp') imshow(a)

b=powerlaw(a,3) imshow(b)

Fig:Original Image Fig:Image after power law

transformation

9

Program No-7

Write a M-File function to provide Contrast stretching (Basic gray-level transformations.)

function [y]=contraststretch1(varargin) aa=varargin{1}; [m n]=size(aa);

a=im2double(aa); sum=0

for i=1:1:m for j=1:1:n

sum=sum+a(i,j); end end sum

pro=m*n; level=sum/pro;(varargin)

S = 1./(1+(level./a).^2) mat2gray(S)

y=S Output:

a=imread('cam.bmp') imshow(a)

b=contraststretch(a) imshow(b)

Fig:Original Image Fig: after contrast streching

10

Program No-8

Write a M-File function to provide THRESHOLDING (Basic gray-level transformations.)

function [y]=threshold(varargin) aa=varargin{1}; [m n]=size(aa);

a=im2double(aa); sum=0

for i=1:1:m for j=1:1:n

sum=sum+a(i,j); end end sum

pro=m*n; level=sum/pro;

for i=1:1:m for j=1:1:n

if a(i,j)<level a(i,j)=0;

else a(i,j)=1;

end end end

mat2gray(a) y=a

11

Output: a=imread('cam.bmp')

imshow(a) b=threshold(a)

imshow(b)

Fig:Original Image Fig:Image after thresholding

12

Program No-9:-

Write a M-File function to plot the histogram of the given image. function histogram(varargin)

u=varargin{1}; [m n]=size(u);

h=zeros(1,255); for j=1:1:m for k=1:1:n if u(j,k)==0

u(j,k)=1; end end end

for j=1:1:m for k=1:1:n

a=u(j,k); h(a)=h(a)+1;

end end

figure(1) imshow(u) figure(2)

bar(h)

Output: >>a=imread('cam.bmp')

>>histogram(a)

Program 10:-

Fig:Original Image Fig:Histogram of Image

13

Write a M-File to remove Gaussian Noise from the given image.

functionlpfgauss(varargin) aa=varargin{1}

f=double(aa) ab=imnoise(aa,'gaussian');

a=double(ab) w=[1 1 1;1 1 1;1 1 1]/9

[m n]=size(a) for i=2:1:m-1 for j=2:1:n-1

a1(i,j)=w(1)*a(i-1,j-1)+w(2)*a(i-1,j)+w(3)*a(i-1,j+1)+w(4)*a(i,j-1)+w(5)*a(i,j)+w(6)*a(i,j+1)+w(7)*a(i+1,j-

1)+w(8)*a(i+1,j)+w(9)*a(i+1,j+1); end end

figure(1) imshow(uint8(a))

figure(2) imshow(uint8(a1))

Output: a=imread('cam.bmp')

lpfgauss(a)

14

S.no Title of program Page no.

Remarks

1

Implement the spatial image

enhancement functions

on a bitmap image -Rotation(clockwise) 1

2

Implement the spatial image

enhancement functions

on a bitmap image-Enlargement (Double

Size) 2

3 To apply Laplacian Transform on image 3

4

Write a M-File function to provide

NEGATIVE transformation

(Basic gray-level transformations 5

5

Write a M-File function to provide LOG

transformation

(Basic gray-level transformations 6

6

Write a M-File function to provide

POWER LAW transformation

(Basic gray-level transformations 8

7

Write a M-File function to provide

Contrast stretching

(Basic gray-level transformations 9

8

Write a M-File function to provide

THRESHOLDING

(Basic gray-level transformations 10

9

Write a M-File function to plot the

histogram of the given image 12

10

Write a M-File to remove Gaussian Noise

from the given image 13

15

Index


Recommended