Page 1 of 1

Extract Multiple Smaller Images from a Large Image.

Posted: 2016-06-10T22:14:08-07:00
by arpeggio
Hi Guys,

I have a many large images like the attached.
http://postimg.org/image/yv52hpk0r/

Each Large Image has multiple (1~5) smaller images (sometimes of different size) pasted. All I need to do is extract those smaller images into separate image files, without any white borders is preferred. Can this be done with ImageMagick? & if so how?

I have been playing with fuzz & trim but doesnt seem to have much effect.
Example:
convert Lge_Image.jpg -fuzz 70% -trim +repage +adjoin Sml_Image_%d.jpg

Thank you in advance,
Arpeggio

Re: Extract Multiple Smaller Images from a Large Image.

Posted: 2016-06-10T23:19:16-07:00
by snibgo
Fred may have a script for this if you use bash.

Trim it, scale to one column, and find the groups of near-white pixels. This gives you the y-coordinates of the positions to crop. After cropping, trim each image.

The file is JPG, so the white areas may not be exctly white.

Re: Extract Multiple Smaller Images from a Large Image.

Posted: 2016-06-11T00:49:37-07:00
by snibgo
Another method, that can be used when the white borders don't cross the entire input image so we can't make simple guillotine cuts:

Turn everything non-white into black, so each subimage is a black rectangle, on a general white background. Use "-connected components" to find them. This directly gives us the crop parameters for the individual pictures.

Re: Extract Multiple Smaller Images from a Large Image.

Posted: 2016-06-11T07:30:19-07:00
by fmw42
I do not understand the problem given that link. I have a script for unix systems (Linux, Mac OSX and Windows with Cygwin) called multicrop. See my link below.

Re: Extract Multiple Smaller Images from a Large Image.

Posted: 2016-06-11T07:42:10-07:00
by snibgo
I suppose he wants to chop the single linked image into three images. Using a "-connected-components" technique, we get these three:
Image
Image
Image