The whole source-to-image algorithm