HPF Image Processing
% High Pass Filter (Sharpening) MATLAB
% Create a 3*3 HPF kernel
kernel = [-1, -1, -1; -1, 17, -1; -1, -1, -1]/ 9;
% Read in the blurred RGB image
im = imread("%FULLPATH%/filename.pictureformat");
% Convolve the HPF kernel with the RGB image Zero Padding
im_zero = imfilter(im, kernel);
% Convolve the HPF kernel with the RGB image Border Replication
im_rep = imfilter(im, kernel, 'replicate');
% Read in the blurred grayscale image
im_gray = imread("%FULLPATH%/filename.pictureformat");
% Convolve the HPF kernel with the grayscale image Zero Padding
im_gray_zero = imfilter(im_gray, kernel);
% Convolve the HPF kernel with the grayscale image Border Replication
im_gray_rep = imfilter(im_gray, kernel, 'replicate');
% Show the images
subplot(3,2,1), imshow(im), title('Blurred RGB image');
subplot(3,2,3), imshow(im_zero), title('Sharpened RGB image with Zero Padding');
subplot(3,2,5), imshow(im_rep), title('Sharpened RGB image with Border Replication');
subplot(3,2,2), imshow(im_gray), title('Blurred Grayscale image');
subplot(3,2,4), imshow(im_gray_zero), title('Sharpened Grayscale image with Zero Padding');
subplot(3,2,6), imshow(im_gray_rep), title('Sharpened Grayscale image with Border Replication');