Hi,
I am new in opencv, i am using opencv 3.0, i am trying to access a sub-image,
As i know there is a 2 ways to do it, using rect or range
using range to access the top quarter of the image
using namespace cv;
int main()
{
Mat img_l = imread("left2.png",IMREAD_GRAYSCALE);
img_l.convertTo(img_l, CV_64FC1); //convert to double in gray scale
Mat leftROI = img_l(Range(0, img_l.rows/2), Range(0,img_l.cols/2));
cv::normalize(leftROI, leftROI, 0, 1, cv::NORM_MINMAX); //to view
imshow("opencvtest1",leftROI);
waitKey(0);
return 0;
}
using rect
using namespace cv;
int main()
{
Mat img_l = imread("left2.png",IMREAD_GRAYSCALE);
img_l.convertTo(img_l, CV_64FC1); //convert to double in gray scale
Mat leftROI = img_l(Rect(0,0, img_l.cols/2 , img_l.rows/2));
cv::normalize(leftROI, leftROI, 0, 1, cv::NORM_MINMAX); //to view
imshow("opencvtest1",leftROI);
waitKey(0);
return 0;
}
However the output images does not seem right, the sub images are no the top left quarter
but when i use matlab
x = imread('left2.png' );
x = rgb2gray(x);
leftROI = x(1:size(x,1)/2,1:size(x,2)/2);
imshow(leftROI)
,
The output of matlab seems right
could anyone help why is opencv not right?