Thursday, March 12, 2009

Laplacian Enhancement

% Laplacian Enhancement
% read a grayscale image and apply the laplacian filter and display the filtered image.
%by appropriately combining filtered laplacian image with the original image.
% use the composite laplacian and enhance the image.
clear all; close all; clc;
a=imread('moon.tif');
a=im2double(a);
subplot(2,2,1),imshow(a),title('Original Image');
[m n]=size(a);
w=[0 1 0; 1 -4 1;0 1 0];
b = imfilter(a,w);
subplot(2,2,2),imshow(b),title('Laplacian-filtered Image');
for i=1:m
for j=1:n
if b(i,j)< 0
rimg(i,j)=a(i,j)-b(i,j);
else
rimg(i,j)=a(i,j)+b(i,j);
end
end
end
subplot(2,2,3),imshow(rimg),title('Laplacian-Enhanced Image');
a = im2double(a);
B =zeros(m,n);
for i=2:m-1
for j=2:n-1
B(i,j) = (5*a(i,j))-(a(i-1,j)+a(i+1,j)+a(i,j-1)+a(i,j+1));
end
end
subplot(2,2,4),imshow(B),title('Composite Laplacian-Enhanced Image');

No comments: