Here is a short sample. Since you mentioned imfreehand
, I included that but depending on what type of ROI you want to create, impoly
or imrect
may do a better job:
img = im2double(imread('cameraman.tif'));
imshow(img);
roi = imfreehand;
img2 = img;
img2(roi.createMask) = 1;
imshow(img2);