0

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 and arbitrarily multithreaded, while still achieving the same end result?

quadrupleslap
  • 460
  • 1
  • 6
  • 18
  • If you look at my answer here http://stackoverflow.com/questions/14377463/connected-component-labeling-with-imagemagick/28429090#28429090 you can see how I do that with ImageMagick. I resized the image there to 2500x2000 (5MP) and it runs in 2 seconds on an iMac. – Mark Setchell Feb 26 '15 at 09:09
  • I tried figuring out how they did it but couldn't find it? Would you mind providing a brief description of how it works? Thanks! =) – quadrupleslap Feb 26 '15 at 13:45
  • If you want to look at some C code and an algorithm, please look at my answer here... http://stackoverflow.com/questions/27925928/color-detection-on-gif-or-png-image – Mark Setchell Feb 26 '15 at 13:47

0 Answers0