Matlab – Laplacian Mask

Another part of Digital Image Processing is the Laplacian mask. Laplacian mask contains the coefficients of the Laplacian operator (second order derivatives). When dealing with Laplacian mask,you must be very careful with the difference in sign when combining either by adding or subtract a Laplacian filtered image with another image. Laplacian operator have some effect. It tends to produce image that have grayish edge lines and other discontinuities in brighter intensities, all superimposed on a dark, featureless background. To correct the problem of featureless background, you must add the original and Laplacian filtered image together.

To understand more about Laplacian mask, take a good look on the example of Matlab code below.

f=imread (‘moon.tif’);

w=fspecial(‘laplacian’,0);
%OR
%w=[0 1 0;1 -1 1;0 1 0];

 

%This will generate image (b) with ALL pixels positive.

%Check workspace

g1=imfilter(f,w,’replicate’);
figure(1),imshow(g1,[]);

 

%g1 is of class uint8.

%need to convert to double first

f2=im2double(f);

%Effect of laplacian mask.

%grayish edge line, featureless background

g2=imfilter(f2,w,’replicate’);

 

%Laplacian filtered image using double formats

figure(2),imshow(g2,[]);

%Restore gray tone lost by using laplacian via subtracting laplacian from
%the original image (substract since center coefficient is negative)

% to correct featureless background – add the original and laplacian filtered image. center of laplacian mask -ve (use minus)
g=f2-g2;
figure(3),imshow(g);

 

That’s all. Thank You

Sharing is Caring

Leave a Reply

Your email address will not be published. Required fields are marked *