title: Laplacian Image Filtering and Sharpening Images in MATLAB
body: <p>I am trying to "translate" what's mentioned in Gonzalez and Woods (2nd Edition) about the Laplacian filter.</p>
  
  <p>I've read in the image and created the filter. However, when I try to display the result (by subtraction, since the center element in -ve), I don't get the image as in the textbook.</p>
  
  <p>I think the main reason is the "scaling". However, I'm not sure how exactly to do that. From what I understand, some online resources say that the scaling is just so that the values are between 0-255. From my code, I see that the values are already within that range.</p>
  
  <p>I would really appreciate any pointers.</p>
  
  <p>Below is the original image I used:</p>
  
  <p><a href="https://i.stack.imgur.com/ti7Ij.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ti7Ij.png" alt="enter image description here"></a></p>
  
  <p>Below is my code, and the resultant sharpened image.</p>
  
  <p>Thanks!</p>
  
  <pre><code>clc;
  close all;
  a = rgb2gray(imread('e:\moon.png'));
  lap = [1 1 1; 1 -8 1; 1 1 1];
  resp = uint8(filter2(lap, a, 'same'));
  sharpened = imsubtract(a, resp);
  figure; 
  subplot(1,3,1);imshow(a); title('Original image');
  subplot(1,3,2);imshow(resp); title('Laplacian filtered image');
  subplot(1,3,3);imshow(sharpened); title('Sharpened image');
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/4kABM.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4kABM.jpg" alt="enter image description here"></a></p>