Search code examples
imagematlabmatlab-figure

shaded region in imagesc figure


Is it possible to shade an area within a figure with an imagesc?

I have a data series that I am analyzing with some function, where the function generates a imagesc figure of the outcome. The original data imported into the function contains some missing values that have been interpolated from previous values and therefore are not accurate. I would like to know if there is a method for placing a shaded region over some part of an imagesc (the interpolated values in my case) figure currently open.

Hope this makes sense, and please ask if I haven't been clear.


Solution

  • You can draw a transparent patch:

    im = imread('peppers.png');
    figure;imshow(im);
    hold on;
    patch([10 10 200 200],[10 200 200 10],[0 0 0],'FaceAlpha',0.5);
    

    The patch can be any polygon. The amount of trasparency is set by FaceAlpha property

    enter image description here