Registration : 21mic7178 Name : Sai Sanjay K
Title : Study of sharpening filters
Aim :
Aim of this experiment is to study the application of sharpening filters to enhance the details and edges in digital images.
Theory :
Frequency Sharpening filters are used to enhance the high-frequency components of an image, making the edges and fine details more pronounced. Unlike smoothing filters that reduce noise and blur the image, sharpening filters highlight transitions in intensity. One common technique is the use of convolution with a sharpening kernel, such as the laplacian filter or the unsharp mask. The Laplacian filter emphasizes regions of rapid intensity change, while the unsharp mask subtracts a smoothed version of the image from the original enhancing edges.
CODE :
% Study of Sharpening Filters
% Load image from MATLAB library load('clown');
% Convert image to double for processing X = double(X);
% Define a Laplacian sharpening filter laplacian_filter = [0 -1 0; -1 4 -1; 0 -1 0];
% Apply the Laplacian filter using convolution sharpened_image = conv2(X, laplacian_filter, 'same');
% Enhance the original image by adding the sharpened detail enhanced_image = X + sharpened_image;
% Display original and sharpened images figure(1);
imshow(X, []); title('Original Image'); figure(2); imshow(sharpened_image, []); title('Sharpened Image'); figure(3); imshow(enhanced_image, []); title('Enhanced Image');
% Read the image
image = imread('your_image.jpg');
% Convert to grayscale if it's a color image
if size(image, 3) == 3
image_gray = rgb2gray(image);
else
image_gray = image;
end
% Display the original image
figure;
imshow(image_gray);
title('Original Image');
% -------------------------------
% Method 1: Using Unsharp Mask
% -------------------------------
% Apply unsharp masking
sharpened_image = imsharpen(image_gray);
% Display the sharpened image
figure;
imshow(sharpened_image);
title('Sharpened Image (Unsharp Mask)');
% -------------------------------
% Method 2: Using Laplacian Filter
% -------------------------------
% Define the Laplacian filter
laplacian_filter = fspecial('laplacian', 0);
% Apply the Laplacian filter
filtered_image = imfilter(image_gray, laplacian_filter, 'replicate');
% Enhance edges by adding the filtered image to the original
enhanced_image = image_gray - filtered_image;
% Display the edge-enhanced image
figure;
imshow(enhanced_image);
title('Edge Enhanced Image (Laplacian Filter)');
% -------------------------------
% Method 3: High-Boost Filtering
% -------------------------------
% Define the high-boost filter
A = 1.5; % Amplification factor (A > 1)
h = fspecial('unsharp', A - 1);
% Apply the high-boost filter
high_boost_image = imfilter(image_gray, h, 'replicate');
% Display the high-boost filtered image
figure;
imshow(high_boost_image);
title('High-Boost Filtered Image');
Sample Results :
Results :
In this experiment, the original image is processed using a sharpening filter. The resulting image displays enhanced edges and finer details, making features more prominent compared to the original. The application of sharpening filters significantly improves the visual clarity of the image, especially at boundaries where there is a noticeable transition in intensity.
Conclusion :
Sharpening filters are effective tools in image processing for enhancing image details and edges. By applying convolution with sharpening kernels, the high-frequency components are amplified, resulting in a clearer and more defined image. This technique is widely used in various applications where detail enhancement is crucial, such as medical imaging, photography, and computer vision.