There is a problem with the angle: atan returns the angle in radians. if you round it, there is little information left ...
Try:
a = atan(y0/x0) * 215 / (pi/2)

This is not the image you expect, it is apparently the inverse transformation, centered in the middle of the image.
# Load the image library(png) library(RCurl) d <- readPNG( getBinaryURL( "http://i.stack.imgur.com/rMR3C.png" ) ) image(d, col=gray(0:255/255))
source share