0

I want to cut a region in a picture with different coordinates.

I have points like that:

  <point x="720" y="549" />
  <point x="805" y="665" />
  <point x="715" y="698" />
  <point x="644" y="582" />

And I want to use them to get a new picture without a mask in the background or something like that. Only the Region from this coordinates. I have something like that: NumPy/OpenCV 2: how do I crop non-rectangular region? But I can not transform it, to my solution. Maybe someone of you can help me.

Thank you! Felix

Felix
  • 105
  • 1
  • 2
  • 11

2 Answers2

0

Have you tried to do something like:

img = img.crop((150, 150, 230, 350))

Where the first 2 coordinates(x,y) are the top left corner and the 2 last coordinates(x,y) are bottom right corner of it.

Note the coordinates are given in pixels.

Oliver H. D.
  • 315
  • 1
  • 6
  • Yes, I tried that, but that only counts for rectangle cuts. My coordinates are not rectangles. – Felix Apr 29 '19 at 20:01
  • Have you tried what is described in the answer in this link: https://stackoverflow.com/questions/15341538/numpy-opencv-2-how-do-i-crop-non-rectangular-region – Oliver H. D. Apr 29 '19 at 20:13
  • Yes, I linked it in my original question. I want only the the not-masked part of the picture. Not more. – Felix Apr 29 '19 at 20:20
0

I have found a solution with this https://jdhao.github.io/2019/02/23/crop_rotated_rectangle_opencv/

Felix
  • 105
  • 1
  • 2
  • 11