Tile transitions between different tiles

Hi everyone! Now I encounter with a problem. I know how to make tile transitions with same tiles, but I don’t know how to make tile transitions between different tiles like this:
http://postimg.org/image/7ey1isz3b/
This example is from Terraria.
I want to know how to do this like in Terraria.

To do tile transitions you need a tileset with transition tiles similar to this. There is not really any other way to do it.

Yes I know that I need tileset, I have it, but I want to know algorithm for making tile transitions like dirt with stone which is used in platform game like terraria.

Here is a good method that I like: http://www.saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/

Ok, I will try it, thanks.