MATLAB: Laplacian for image sharpening Implementation

convolutiondigital image processingImage Processing Toolboximage sharpeninglaplacianMATLAB

I am trying to implement the discrete laplacian of two variables for image sharpening but wanted to confirm with the community that my reasoning behind what I am doing is right. I understand that the laplacian is:
(Eq. 1)
which can be expressed discretely as:
(Eq. 2)
This equation can be expressed as the laplacian kernel:
(Kernel 1)
My text book gives 3 other laplacian kernels which are:
(Kernel 2) (Kernel 3) (Kernel 4)
Finally image sharpening can be achieved with:
(Eq.3)
Where c is positive for the kernels above with a positive center and c is negative for kernels with a negative center.
I understood from the book that the onvolution of an image with one of these kernels would be the equivalent of impementing Eq. 2above (discrete laplacian of two variables). and then based on the kernel I pick I either add or subtract the output of the convolution with the original image as in Eq. 3 to get my image sharpening.
I have tried implementing this in some matlab code below but cannot replicate what my book is asking for. Can anyone see a mistake I made in my code for either the convlution or image sharpening?
Edit – The issue was not with the convolution or laplacian kernel but with the way I plotted my graphs. Please contact me if you want my code for doing this thanks.
figure,
subplot(231),imshow(image,[]);title('Original Image - Input');axis on;
subplot(232),imshow(output, []);title('Laplacian Convolved with Kernel - Unscaled');axis on;
subplot(233),imshow(output,[0,255]);title('Laplacian Convolved with Kernel - Scaled');axis on;
subplot(234),imshow(filtered_Image,[]);title('Image Sharpening using the Laplacian');axis on;
subplot(235),imshow(laplacian, []);title('Matlab Function Test for Laplacian');axis on;
subplot(236),imshow(image_Sharpen, []);title('Matlap Built in Image Sharpening');axis on;

Best Answer

I figured out the issue for anyone interested. The method I used for my conolution with the image and kernel works fine and the method for adding and subtracting works as well since the images are the same size. The issue was that when I plotted with imshow(A, []) the image is scaled by the min and max values of the image due to the [] operator which looks like this:
imshow(I , []) = imshow(I, [min(:) max(:)])
Where the min and max take the min and max number of the image. This as scaling the ouput of my figures and cutting off some potnetial intensity levels. I plotted using using just the imshow and this worked a lot better.
So basically I changed my plot code too:
figure,
subplot(231),imshow(image);title('Original Image - Input');axis on;
subplot(232),imshow(output);title('Laplacian Convolved with Kernel - Unscaled');axis on;
subplot(233),imshow(output, []);title('Laplacian Convolved with Kernel - Scaled');axis on;
subplot(234),imshow(filtered_Image);title('Image Sharpening using the Laplacian');axis on;
subplot(235),imshow(laplacian);title('Matlab Function Test for Laplacian');axis on;
subplot(236),imshow(image_Sharpen);title('Matlap Built in Image Sharpening');axis on;