Reputation: 1235
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:
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!
Upvotes: 0
Views: 526
Reputation: 21563
I can't try it at the moment, but I think you want to put one image on top of eachother.
Assuming that the top image is NaN
on places where you can see the second image:
idx= ~isnan(frontimage)
backimage(idx) = frontimage(idx)
You may need to do some padding or scaling first as this requires the images to be of the same size.
Upvotes: 0
Reputation: 104464
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.
Upvotes: 2