MATLAB: Image smoothing & sharpening of a particular region in an image

image processingImage Processing Toolboximage sharpeningimage smoothing

How to apply image smoothing & sharpening to only a particular region of an image?
I'm supposed to take a corrupted and noisy image. Select a particular region of interest. Then apply smoothing and/or sharpening only to that region using MATLAB codes. The code should be generalized i.e i should be able to apply that code to any image. Won't there be problem with selecting the threshold levels for smoothing and/or sharpening for each image, if we are supposed to generalize?
Can anyone give the MATLAB code for the above problem?

Best Answer

I'd just smooth the whole thing and then multiply by the mask defining the regions. There are more efficient methods, but for most situations this will be fine.
blurredImage = conv2(grayImage, ones(15)/15^2, 'same');
grayImage(maskImage) = blurredImage(maskImage);
I don't know what you want to do with thresholds. I guess that might affect how your blurred or sharpened image is created, but you don't say exactly so I can't tell.