How can following overlapping be performed?
Note: Mask can be created with any of R G B layer, because black areas are completely black, i.e. '0' for each R G B's. In this way efficiency can be improved.
In MATLAB this can be done with:
mask = (Im2> 0); % masking 3 channels (computationally expensive)
Im1(mask) = Im2(mask); % Im1 will become the final overlapped image