Search code examples
matlabadobe-illustrator

Superimpose two figures


I have two figures - one is a phylogenetic tree and the other is a skyline plot (a line plot with shaded bits).

I want to superimpose the tree onto the skyline, like this:

enter image description here

Both figures are tiff files with white backgrounds.

Is this possible with MATLAB? My line plot is made with MATLAB.

I also have illustrator (CS6) but am a complete newbie to that...

Thanks!


Solution

  • Load in both images, then merge them assuming a transparency of 0.5. As such, let's say your tree diagram was in an image called imtree and the skyline plot is in an image called imskyline. Load these into MATLAB, then simply do this sum:

    out = uint8(0.5*double(imtree) + 0.5*double(imskyline));
    

    After this, display your image using imshow(out); and see what it looks like. Hopefully this will work, as I don't have access to your actual images!

    You may have to play around with the constants. Perhaps weight the tree more while the skyline plot less. If the above doesn't work, try something like:

    out = uint8(0.75*double(imtree) + 0.25*double(imskyline));
    

    Alternatively, if the above doesn't work, try doing imfuse to blend the two images together in a natural way:

    out = imfuse(imtree,imskyline,'blend','Scaling','joint');
    

    What the above code does is that it blends the images naturally, and scales the colours between the two images in such a way that they will play nicely with each other.