MATLAB: How can i change the contrast at few locations in an image

image processingImage Processing Toolbox

I want to lower the contrast at particular locations in an image but not the whole image. Is there any way to change it just by clicking some places on image and giving our desired grey color without specifying coordinate points??

Best Answer

Somehow the "particular" locations must be specified, don't you agree? If you don't know the "coordinate points" of the areas to be included and excluded then you don't know what locations to reduce the contrast in, right?
You need to have a binary mask. Then filter the whole image, but replace the masked areas by the original. For example
mask = false(rows, columns); % Initialize
mask(1:rows/2,:) = true; % Mask top half of image.
% Now do your filtering on the whole image.
% Now replace top half with original image:
filteredImage(mask) = grayImage(mask);