MATLAB: Matlab code sharpening a image

Image Processing Toolboxplease tell me the matlab code for a single image sharpening?

please tell me the matlab code for a single image sharpening?

Best Answer

You can use conv2() or imfilter(). For example
kernel = -1 * ones(3)/9
kernel(2,2) = 8;
kernel = kernel / sum(kernel(:)); % Normalize sum to 1.
% High frequency boost filter
sharpenedImage = conv2(double(grayImage), kernel, 'same');
imshow(sharpenedImage);
That's one way. Or you can use a Difference of Gaussians image built with two calls to imgaussfilt(), or two to fspecial and then one to imfilter (which might be faster than two imgaussfilt() calls).