implementing intensive depthmap processing algorythm from elsamuko - ported from cpp