How i can do image CROP in OpenCV

Posted by Nolik on Stack Overflow See other posts from Stack Overflow or by Nolik
Published on 2013-03-23T17:00:43Z Indexed on 2013/10/21 15:54 UTC
Read the original article Hit count: 149

Filed under:
|

How i can do image crop such in PIL in OpenCV.

Working example on PIL

im = Image.open('0.png').convert('L')
im = im.crop((1, 1, 98, 33))
im.save('_0.png')

But how i can do it on OpenCV?

I wanted to do so

im = cv.imread('0.png', cv.CV_LOAD_IMAGE_GRAYSCALE)
(thresh, im_bw) = cv.threshold(im, 128, 255, cv.THRESH_OTSU)
im = cv.getRectSubPix(im_bw, (98, 33), (1, 1))
cv.imshow('Img', im)
cv.waitKey(0)

But it doesnt work.

I think, i wrong use getRectSubPix. If it true, please explain how i can correctly use this function.

Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about opencv