gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
How can I convert in Python a list of polygon tuples like this "1215,969 3268,1010…
- User
How can I convert in Python a list of polygon tuples like this "1215,969 3268,1010 3309,1119 3322,3835 3322,4501 3281,4597 1338,4624 464,4583 491,1051 519,996 1215,969" from an image of 4607x6143 to same format but to the same image resized to 720x960 ?
- Assistant
To convert a list of polygon tuples from the original image size (4607x6143) to a new image size (720x960), you need to scale each coordinate based on the ratio of the new dimensions to the original dimensions. Here's how you can achieve this in Python:
- Parse the polygon string into a list of (x, y) tuples.
- Calculate the scaling factors for the width and height.
- Scale each coordinate and format it back into the desired string format.