fix crash when sample point out of image boundaries

Sample point goes out of image boundaries under certain circumstances. This causes crash as point is used for pointer arithmetic [here](https://github.com/mapycz/opencv/blob/4c426fe26ecbefc4568136083644d50ca1a30ac7/modules/photo/src/calibrate.cpp#L107).