If the final, filled in region is convex, it can be obtained as follows
layers=false(5,5,3)
layers(:,:,1)=1;
layers(3,3,3)=1;
T=regionprops3(double(layers),'ConvexImage','SubarrayIdx')
layers(T.SubarrayIdx{:})=T.ConvexImage{1}
layers(:,:,1) =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
layers(:,:,2) =
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
layers(:,:,3) =
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
