Finding edges & splitting image into multiple

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Posts: 1
Joined: 2020-03-14T14:51:36-07:00
Authentication code: 1152

Finding edges & splitting image into multiple

Post by fadams99 »

I have a large number of scanned images as combined photos (8 photos per file) and I was wondering how I can automate the process of finding the edges of each individual image and splitting it into its own .jpg . Is this possible? Below is an example of the type of thing I am dealing with.

Help is appreciated!

Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Finding edges & splitting image into multiple

Post by snibgo »

I show some methods at Subimage rectangles.
snibgo's IM pages:

User avatar
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Finding edges & splitting image into multiple

Post by fmw42 »

If on a Unix-like system, see my scripts: multicrop and multicrop2 at my link below.

Otherwise, convert the image into binary (black where the images exist and white for your background) as a mask. Then use connected components to get the bounding boxes of the black regions from the mask. The use those bounding boxes to crop your actual input image.