Added proper conversion between pixel space and real space. Still needs to be tested.