%
% Image sharpening using Laplacian and Sobel
% Written by: H.E.
% Date: 2/2009
%

close all;
clr={'R','G','B'};

file='c:\Hector\EE_552\Images\ITCH\L B1 002 S 090407.bmp';
im=imread(file); figure; subplot(3,3,1); imagesc(im);
title('Ophtalmic Lens');

im=double(im);
L=im; S=im;
[x,y,z]=size(im)
L_m=[-1 -1 -1; -1 8 -1; -1 -1 -1];
S_m=[-1 -2 -1;  0 0  0;  1  2  1];

for c=1:3
    for i=2:x-1
        for j=2:y-1
            L(i,j,c)=sum(sum(im(i-1:i+1,j-1:j+1,c).*L_m));
            S(i,j,c)=sum(sum(im(i-1:i+1,j-1:j+1,c).*S_m));
        end
    end
    subplot(3,3,3+c); imagesc(L(:,:,c)); colormap(gray);
    titL=['Laplacian ' clr{c}]; title(titL);

    subplot(3,3,6+c); imagesc(S(:,:,c)); colormap(gray);
    titL=['Sobel ' clr{c}]; title(titL);
end
