get the actual position correspond to imfreehand
1 view (last 30 days)
Hi I have a question. I have a grayscale image, I chose a region using imfreehand command and I have its position. I can convert to the mask but that is a binary image how can I extract the exact image that is correspond to region of imfreehand from the grayscale image. Meaning that imcrop returns the cropped version of grayscale image I want to do the same thing here.
Then I like to have something like image(pos) to extract the portion from grayscale image. However this is of course is a error because the subscript is a fraction.
Ben11 on 17 Aug 2014
After you get the position, you can create a mask in which value inside the ROi are equal to 1 and those outside are equal to 0. Then you assign those 0-values to the original image. Please try the following code and see what happens, is this what you want to achieve?
A = rgb2gray(imread('peppers.png'));
hRoi = imfreehand(gca);
Position = getPosition(hRoi);
BW = createMask(hRoi);
A(BW == 0) = 0;