Opencv Local Maxima, Local maxima and minima are applied to the region covered by your mask not the whole image.