mardi 24 février 2015

Most efficient way to get sub-image bounds from an image

In English, this is what I'm currently doing to separate my image into sub-images:



  1. Use flood fill to iterate the image and get a list of 'islands' - individual blocks of pixels fully surrounded by transparency.

  2. Now for each island, make a box around it. Collect these boxes in a list.

  3. Now check for intersections between the boxes, and join any intersections. Then stop checking, and start again from the start of the list.

  4. Now make a sub-image for each box and, iterating one last time, save each one of them to the specified output directory.


However, this is really inefficient, and takes at least 10s for a 5MP image on my unoptimised Node implementation of this process. How would I make this process more efficient, while still achieving the same end result?


Aucun commentaire:

Enregistrer un commentaire