Those of you who have worked with image processing tools have probably been wondering if a manual, freehand selection of a ROI is possible in MATLAB. This is an extremely useful tool, since there are many applications with ROIs, which should be very tightly defined in order to be efficiently masked. This is another area in which MATLAB doesn't fall short of competitive tools. In fact, there are two possible choices; a polygonal ROI defined by many points can be defined using roipoly
, while function imfreehand
can be used for accomplishing a totally free selection. Let's see how we can use them.
We will start with our three rock images in order to explain the process of making a mask using roipoly
. First, we will load, convert, and crop our image (to make our results more visible):
>> img = imread('3rocks.jpg'); >> rock = rgb2gray(img); >> rock = imcrop(rock)
Then, it is time to call roipoly
and define the...