Return Reference to Bitmap from getBitmap
Return Reference from create2dDistanceHistogram

This makes clear that pointer ownership is transfered to the caller.
See see GotW 90 solution 2 at
http://herbsutter.com/2013/05/30/gotw-90-solution-factories/