0

I have a photo like this

enter image description here

And I want to create a mask for every images in this photo, so that I can cut it and have single photos. I hope you could understand my intention.

How can I do this in python?

My goals are:

  1. Step create mask for this image in python if possible (So I think I have to write a function which can detect the edges and create a mask. Is that a good idea or should the masking process be done with Photoshop or GIMP?)
  2. Define a python function to cut images based on the mask with opencv (Yeah I could do the cutting process with Photoshop as well but I have like 10 different images and I want to automate this process.)

This answer here 'How do I crop an image based on custom mask in python?' is already good but not exactly what I want, how can I extend the function?

Takuya2412
  • 187
  • 10
  • 1
    For regular rectangle shapes, you do not need a mask, just the coordinates of each rectangle's corners. A mask is a pixel-by-pixel true-or-false bitmap image, which is not necessary in your case. – Guang Oct 27 '21 at 16:04
  • you have a white background. It shouldn't be difficult to get the image masks by removing it. But if you just have 10 images and don't know how to start with the code, you'd better do it manually. The questions as is is also too broad for SO standards – Miki Oct 27 '21 at 16:11

0 Answers0