From: eli goodwin on
I am trying to write short for-loop that creates a specified number of roipoly() masks, storing the specified masks in an multidimensional array.
example:

num_masks = input('How many masks would you like to draw?');
for k=1:num_masks
[frame, Map] = frame2im(immov(1));
image(frame);
imwrite(frame, 'frame.jpg', 'jpg');
i=imread('frame.jpg');
mask=roipoly(i);
......

Further, I need to add another dimension to each array stating what color it is masking
example:
maskcolor = input('What is the mask color? (red/yel) ','s');
if maskcolor==red
......
I would like to have the array structured such that the first dimension is the mask#, the second dimension is x,y coordinates, and 3rd dimension is the string input from mask color.
Suggestions?
From: ImageAnalyst on
Why don't you just have an array of structures? Each structure could
have members that are the mask image, the coordinate, the color, and
whatever you want. In the loop, you'd just do something like

strMasks(k).maskImage = mask; % returned from roipoly or
roipolyold
strMasks(k).xi = xi; % returned from roipoly or roipolyold
strMasks(k).yi = yi; % returned from roipoly or roipolyold
strMasks(k).maskColor = maskcolor;
% etc.