0% found this document useful (0 votes)
2 views

exp_4

The document outlines a program that applies high-pass and Laplacian filters to sharpen image details. It includes steps for reading an image, converting it to grayscale, applying the filters, and displaying the original and processed images along with their histograms. The results demonstrate the effectiveness of both filtering methods in enhancing image sharpness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

exp_4

The document outlines a program that applies high-pass and Laplacian filters to sharpen image details. It includes steps for reading an image, converting it to grayscale, applying the filters, and displaying the original and processed images along with their histograms. The results demonstrate the effectiveness of both filtering methods in enhancing image sharpness.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programme #4

Apply high-pass and Laplacian filters to sharpen image details, analyze before and after
images.
clc;
clear;
close all;
% Read the image
img = imread('image.jpg'); % Replace 'image.jpg' with your image file
if size(img, 3) == 3
img_gray = rgb2gray(img); % Convert to grayscale if RGB
else
img_gray = img;
end
% High-pass filter kernel
hp_filter = [-1 -1 -1; -1 8 -1; -1 -1 -1];
% Apply high-pass filter
high_pass_img = imfilter(img_gray, hp_filter, 'same', 'replicate');
% Laplacian filter kernel
laplacian_filter = [0 -1 0; -1 4 -1; 0 -1 0];
% Apply Laplacian filter
laplacian_img = imfilter(img_gray, laplacian_filter, 'same', 'replicate');
% Sharpened images
sharp_hp = img_gray + high_pass_img;
sharp_lap = img_gray + laplacian_img;
% Display results
figure;
subplot(2,3,1); imshow(img_gray); title('Original Image');
subplot(2,3,2); imshow(high_pass_img, []); title('High-pass Filtered Image');
subplot(2,3,3); imshow(sharp_hp, []); title('High-pass Sharpened Image');
subplot(2,3,4); imshow(laplacian_img, []); title('Laplacian Filtered Image');
subplot(2,3,5); imshow(sharp_lap, []); title('Laplacian Sharpened Image');
% Histogram analysis
figure;
subplot(1,3,1); imhist(img_gray); title('Histogram - Original');
subplot(1,3,2); imhist(sharp_hp); title('Histogram - High-pass Sharpened');
subplot(1,3,3); imhist(sharp_lap); title('Histogram - Laplacian Sharpened');

You might also like