Maybe this:
[rows, columns, numberOfColorChannels] = size(I);
binaryImage = false(rows, columns);
for i = 1:numparts
x1 = A(1,1+(i-1)*4);
y1 = A(1,2+(i-1)*4);
x2 = A(1,3+(i-1)*4);
y2 = A(1,4+(i-1)*4);
line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','color',colorset{i},'linewidth',2);
binaryImage(y1:y2, x1:x2) = true;
end
imshow(binaryImage);