1 year ago
#368225
Joan Albert
How to crop images in irregular shapes/polygons?
I'm trying to crop an image by coordinates, in an irregular shape. I do have the following polygon of coordinates where I have to draw a line and cut and keep only this polygon from the image.
These are the cooridnates (inside a canvas, starting clockwise)
"polygon": [
[0.152, 0.416],
[0.16, 0.186],
[0.172, 0.02],
[0.211, 0.006],
[0.357, 0.006],
[0.592, 0.006],
[0.656, 0.023],
[0.775, 0.043],
[0.789, 0.055],
[0.756, 0.549],
[0.756, 0.637],
[0.736, 0.955],
[0.719, 0.994],
[0.607, 0.996],
[0.197, 0.996],
[0.131, 0.994],
[0.123, 0.982],
[0.125, 0.855],
[0.139, 0.668],
[0.139, 0.584]
],
What would be the best way/approach or tool to do this kind of job?
Inputs: image + coordinates of a polygon inside this image Output: the polygon inside the image (or transparent/paint white the rest of the pixels that are not included inside the polygon)
javascript
node.js
image
image-processing
crop
0 Answers
Your Answer