Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Roi to small?

Hi,

I am using ROIs to crop my images and I just noticed that the ROIs are always one pixel to small.

Actually I am not sure whether I misunderstood how I select a roi or whether there is something wrong.

For example if I select a Roi from a Mat with 100 rows and the roi shall have the same height I do it with these points: Point(x1,0), Point(x2,Mat.rows-1). I thought from 0 to 99 is 100 and would select the full Mat height, but this is not the case.

See this example:

#include <opencv2/opencv.hpp>
#include <iostream>
cv::Mat test = cv::Mat::zeros(cv::Size(1000, 100), CV_64FC1);
cv::Rect ROI(cv::Point2i{0,0},cv::Point2i{319,test.rows-1});

std::cout << "Cols: " << ROI.width << " Rows: " << ROI.height << std::endl; //Returns 99, 319 instead of 100, 320

Why is that? Thank you very much!