MATLAB: How to create mask for the 2 plotted circle on the same image

create mask

I = imread('Image1.jpg');
NoseDetect = vision.CascadeObjectDetector('Nose','MergeThreshold',30);
BB=step(NoseDetect,I);
HSV = rgb2hsv(I);
imshow(HSV);hold on
nbox = step(NoseDetect, I);
nx = nbox(1) + nbox(3)/2;
ny = nbox(2) + nbox(4)/2;
theta = 0 : 0.01 : 2*pi;
radius = 45;
final_x = nx - 145;
final_y = ny - 25;
X = radius * cos(theta) + final_x;
Y = radius * sin(theta) + final_y;
plot(X, Y, 'b-', 'LineWidth', 1);
hueImage = HSV(:,:,1);
satImage = HSV(:,:,2);
valueImage = HSV(:,:,3);
[rows, columns] = size(hueImage);
mask = poly2mask(X, Y, rows, columns);
imshow(mask);hold on
final_x = nx + 145;
final_y = ny - 25;
X2 = radius * cos(theta) + final_x;
Y2 = radius * sin(theta) + final_y;
plot(X2, Y2, 'b-', 'LineWidth', 1);
hueImage = HSV(:,:,1);
satImage = HSV(:,:,2);
valueImage = HSV(:,:,3);
[rows, columns] = size(hueImage);
mask = poly2mask(X2, Y2, rows, columns);

Best Answer

Get a mask1 and mask2 and or them together.
mask = mask1 | mask2;