1

I have a Mat and I successfully cropped the ROI (lower-half part of image). But the problem is, I want the upper-half part of image to be blank(white in color) and the cropped image in the lower-half. Here is my existing code -

Rect imgROI(0, temporaryImage.size().height - (temporaryImage.size().height / 2), temporaryImage.size().width, temporaryImage.size().height / 2);
Mat croppedImage = temporaryImage(imgROI);

Any ideas on how to do that?

FadedCoder
  • 1,517
  • 1
  • 16
  • 36

1 Answers1

1

Just set ROI of upper-half to zero:

  cv::Rect blankRoi(0, 0, temporaryImage.size().width, temporaryImage.size().height / 2);
  temporaryImage(blankRoi).setTo(cv::Scalar(0));
akarsakov
  • 2,134
  • 4
  • 21
  • 26