How to cut image to smaller pieces? [closed]
I need to cut image in half and each of them save as different one. For example I have image in grayscale and I try to do it like this:
halfImg[0] = Mat(greyimg, Rect(0, 0, 163, 93)).clone();
halfImg[1] = Mat(greyimg, Rect(164, 0, 327, 93)).clone();
but the second one generates this error:
Is there another way to do it in Open CV?
Your Rect expects x, y, width and height, so if you give 164(x)+327(width)=491 on x, does the coordinate exists? What is the size of your greyImage?
So, Is it possible that I just keep using Rect() wrong way? My image has size of 327x93.
take a look at http://answers.opencv.org/question/82641 you can adapt @thdrksdfthmn 's answer to divide your image vertically
Thanks! Now I understand what I did wrong. I did not know that the coordinates add up in this function. Your first comment helps me alot.
This is correct way.
it is still uncorrect. tell me why?
No, this is correct now.
you have two images both witdh is 163 :) check this one
or