How do I sharpen/refocus an image using only the fspecial and conv2 commands?

11 views (last 30 days)
We are studying simple convolution in my class. So far we have convolved 2 signals and reduced noise from sine waves. Now we've an assignment to refocus an image.
This is my code so far:
x=imread('Sgrayblur.png');
h=
y=conv2(x,h);
subplot(1,2,1),imshow(x);
subplot(1,2,2),imshow(y);
What must I put after 'h='? Is it possible to use fspecial to sharpen without using imfilter or the like?

Answers (1)

Image Analyst
Image Analyst on 14 Apr 2015
You can use a Laplacian to get a high pass filter, then add it to the original image to sharpen the edges. Of course because convolution is a linear filter, you can simply add the kernels together and do a convolution once. So a 3 by 3 filter for a high boost filter would be:
kernel = [-1, -1, -1; -1, 17, -1; -1, -1, -1]/ 9;
sharpenedImage = conv2(double(grayImage), kernel, 'same');
You can use imfilter() instead of conv2() if you want.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!