fixed slow down in getRectSubPix (original patch by Markus JR Mueller)

see PR #1738 ... and removed some unused variables and functions