% Fig. 3.38
% Laplacian with scaling
% Dr. W.D.Pan, UAH

I = imread('Fig0338(a)(blurry_moon).tif');
imshow(I,'initialmagnification','fit');

I2 = im2double(I);

h = fspecial('laplacian', 0)
J2 = imfilter(I2, h, 'replicate');
% Without scaling
imshow(J2, 'initialmagnification','fit');
% With scaling
imshow(J2, [], 'initialmagnification','fit');

 
% Image Sharpening
g1 = double(I) - J2;
figure; imshow(g1, [], 'initialmagnification','fit');

% Image Sharpening using W8
h8 = [1 1 1; 1 -8 1; 1 1 1];
J8 = imfilter(I2, h8, 'replicate');
imshow(J8, [], 'initialmagnification','fit');
g8 = double(I) - J8;

figure; imshow(g8, [], 'initialmagnification','fit');