You are using ROI to select 3X3 region, then why don’t you use the same ROI to set pixel.
For example
Mat src;//source image
Rect R(x,y,W,H); //ROI rect
Mat ROI=src(R);
getminmaxonROI() //get your minmax
suppose you got minimax location like ROI_X and ROI_Y and in your source image it will be like,
SRC_X=ROI_X+R.x;
SRC_Y=ROI_Y+R.y;