Answers for "Low Pass Filter Image Processing"

0

High Pass Filter 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');
Posted by: Guest on April-26-2022
0

Low Pass Filter Image Processing

% Low Pass Filter (Smoothing) MATLAB


% Create a 3*3 Averaging LPF
f_average = fspecial('average', 3);


% Read in the original RGB image
im = imread("%FULLPATH%/filename.pictureformat");

% Apply the LPF to the RGB image Zero Padding
im_average_zero = imfilter(im, f_average);

% Apply the LPF to the RGB image Border Replication
im_average_rep = imfilter(im, f_average, 'replicate');


% Convert the RGB image into grayscale
im_gray = rgb2gray(im);

% Apply the LPF to the grayscale image Zero Padding
im_gray_average_zero = imfilter(im_gray, f_average);

% Apply the LPF to the RGB image Border Replication
im_gray_average_rep = imfilter(im_gray, f_average, 'replicate');


% Show the images
subplot(3,2,1), imshow(im), title('Original RGB image');
subplot(3,2,3), imshow(im_average_zero), title('Smoothed RGB image with Zero Padding');
subplot(3,2,5), imshow(im_average_rep), title('Smoothed RGB image with Border Replication');
subplot(3,2,2), imshow(im_gray), title('Original Grayscale image');
subplot(3,2,4), imshow(im_gray_average_zero), title('Smoothed Grayscale image with Zero Padding');
subplot(3,2,6), imshow(im_gray_average_rep), title('Smoothed Grayscale image with Border Replication');
Posted by: Guest on April-26-2022

Code answers related to "Low Pass Filter Image Processing"

Browse Popular Code Answers by Language