This time we are going to make a more complex tool. We'll write a function that accepts an image as an input, prompts the user to select a ROI (using either one of the two methods described previously) and then prompts the user to select a pixel with the color to be used for the erasing process. Finally, it will use the color of the pixel chosen by the user to erase the area defined by the mask. The code will be something like as follows (we'll call it FreehandMasking.m
):
function[output] = FreehandMasking(input,method) % Function that performs masking of a user-defined ROI % Inputs: % input - Input image % method – ROI selection (1: roipoly, 2: imfreehand) % Output: % output - Output image (masked) switch method case 1 mask = roipoly(input);););% Select ROI using roipoly case 2 figure, imshow(input) h = imfreehand; % Select ROI using imfreehand pos = wait(h); [rows,columns] = size(input); mask...