extracting multiple pages from one image

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
analyst
Posts: 4
Joined: 2016-07-17T05:22:32-07:00
Authentication code: 1151

extracting multiple pages from one image

Post by analyst » 2016-07-17T05:29:40-07:00

I have 3 pages scanned in the 1 image. How do I extract them ?

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

Re: extracting multiple pages from one image

Post by snibgo » 2016-07-17T05:41:12-07:00

Wave a magick wand.

If you want a more helpful answer, you could provide an example image.
snibgo's IM pages: im.snibgo.com

analyst
Posts: 4
Joined: 2016-07-17T05:22:32-07:00
Authentication code: 1151

Re: extracting multiple pages from one image

Post by analyst » 2016-07-17T05:51:16-07:00

how do I attach an image to this board. I look carefully and could not find it.

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

Re: extracting multiple pages from one image

Post by snibgo » 2016-07-17T05:57:02-07:00

Upload to somewhere like dropbox.com and paste the URL here.
snibgo's IM pages: im.snibgo.com

analyst
Posts: 4
Joined: 2016-07-17T05:22:32-07:00
Authentication code: 1151

Re: extracting multiple pages from one image

Post by analyst » 2016-07-17T06:08:10-07:00

multicrop -f 10 -u 2
is not working because background apparently sucks.

http://www.fmwconcepts.com/imagemagick/multicrop2


Image Link:
https://drive.google.com/open?id=0Bx0mR ... lBYZHJndlE

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

Re: extracting multiple pages from one image

Post by snibgo » 2016-07-17T06:42:31-07:00

There are no straight lines that will separate the books from each other. A general method is unlikely to work for images like this.

If the books are always laid out like this, you could write a custom script. For example, finding the four corners of the right-hand book is easy, so it can be isolated and corrected for perspective. But where is the boundary of the two left-hand books? There is a small background area on the left, but extending that horizontally to the right would chop text from the upper book.

You would need to follow the curved shadow between the books. Eg make that shadow black, and use it as the boundary between the books. You know the other edges, so the other boundaries can be painted black, the books painted white, and use connected-components.

Then, dividing each book into two pages is simpler.

So, it could be done, but not easily.
snibgo's IM pages: im.snibgo.com

analyst
Posts: 4
Joined: 2016-07-17T05:22:32-07:00
Authentication code: 1151

Re: extracting multiple pages from one image

Post by analyst » 2016-07-17T06:51:15-07:00

I will use this thread to document my experience. To start with, what is the command(s) to find the curved shadow in general ?

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

Re: extracting multiple pages from one image

Post by snibgo » 2016-07-17T07:15:14-07:00

This makes the curved shadow between the left-hand books black:

Code: Select all

convert sixPages.jpg -colorspace Gray -blur 0x5 -unsharp 0x5+100+0 -threshold 40% x.png
Assuming the two left-hand books have been cropped out, the widest black connected-component is the shadow.

EDIT: -blur 0x5 works better.
snibgo's IM pages: im.snibgo.com

Post Reply