Overlaying Masks by Converting to RGB
### Overlaying two masks by converting them to an RGB image
# Convert first mask to a RED RGB image
# Note: np.newaxis is a trick to add a third axis to the 2D mask!
rgb_mask_1 = some_binary_mask[:,:,np.newaxis] * np.array([255,0,0])
# Convert second mask to a BLUE RGB image
rgb_mask_2 = another_binary_mask[:,:,np.newaxis] * np.array([0,0,255])
# Merge the two images with a maximum projection (yielding MAGENTA for overlaying pixels)
full_rgb = np.max([rgb_mask_1, rgb_mask_2], axis=0)
# Plot it (matplotlib recognizes RGB-shaped arrays automatically)
plt.figure(figsize=(12,12,))
plt.imshow(full_rgb, interpolation='none')
plt.show()