imgproc: add parameter checks in calcHist and calcBackProj