0

I want to resize an image with cv2 so that the image is only as big as 100x100 and display it with imshow.

From:

enter image description here

To:

enter image description here

Is there a function in cv2 that leaves out part of the image?

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Phil
  • 624
  • 7
  • 19
  • 2
    See "region of interest"
    ([Region of Interest opencv python][3] - StackOverflow) [3]:https://stackoverflow.com/questions/15424852/region-of-interest-opencv-python
    – busybyte Mar 09 '19 at 21:31

1 Answers1

2

Thanks to busybyte I found the answer:

img = cv.imread("PATH")
centerx, centery = [int(img.shape[0] / 2) - 50, int(img.shape[1] / 2) - 50]
img = img[centerx:centerx + 100, centery:centery + 100]

Which crops the image to the wanted size of 100x100 from the centre.

Phil
  • 624
  • 7
  • 19