Need help with Crop command after Perspective command

Discussion about Steve DeVore's Book Scan Wizard, a power-user package to automate scan processing.

Moderator: peterZ

User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Need help with Crop command after Perspective command

Post by rob »

OK, so this is the first time I'm using BSW. I have my images in L and R folders. I set up a new project, set the DPI to 99 (as measured), and now I have the project open.

So I skipped a few of the first pages to get to the first left page with full content. I selected four corners in the text block, right clicked, and selected Fix Perspective. Then I chose two corners, right clicked, and selected Crop. BSW threw an exception:

Code: Select all

java.lang.IllegalArgumentException: Crop The rectangular crop area must not be outside the image. for 863,792, 5849,8043 # BSW_0008 L (IMG_0007)
The relevant script:

Code: Select all

########################################################################
### Insert commands to fix keystone, color, etc.

Pages = left
Perspective =  1541,1516, 5530,1479, 5542,7255, 1523,7234 # BSW_0008 L (IMG_0007)
Crop =  863,792, 5849,8043 # BSW_0008 L (IMG_0007)
So I don't quite understand: the crop rectangle is always going to be outside the perspective points because the perspective points are measured using the text block, while the crop points are measured with some margin outside the text block.

So... confused?

--Rob
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Need help with Crop command after Perspective command

Post by steve1066d »

Hmmm.. What are the dimensions of your source image?
Steve Devore
BookScanWizard, a flexible book post-processor.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: Need help with Crop command after Perspective command

Post by rob »

Source image (after rotation) is 2448 x 3264. That's a good point. How did BSW come up with coordinates higher than that?
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Need help with Crop command after Perspective command

Post by steve1066d »

Thats a good question. Can you send me the entire configuration?
Steve Devore
BookScanWizard, a flexible book post-processor.
steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Need help with Crop command after Perspective command

Post by steve1066d »

Just a wild guess here.. but if you had a scale operation (like ScaleToDPI), that was originally before the crop, and you moved it to after the crop, that would do it.

In any case, you might try redoing the perspective command.
Steve Devore
BookScanWizard, a flexible book post-processor.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: Need help with Crop command after Perspective command

Post by rob »

Here's the script:

Code: Select all

# Book Scan Wizard Script 
# http://bookscanwizard.sourceforge.net
#   /Users/robertbaruch/Desktop/desktop_crap/BookImages/LexiconVol2


# the source directory, with subdirectories for left & right files
LoadLRImages = /Users/robertbaruch/Desktop/desktop_crap/BookImages/LexiconVol2

# Override source DPI
SetSourceDPI = 90

# The Destination directory
SetDestination = /Users/robertbaruch/Desktop/desktop_crap/BookImages/LexiconVol2/tiff

# Sets the final DPI and compression
SetTiffOptions = 300 NONE

# Configure the left pages
Pages = left
Rotate = -90

# Configure the right pages
Pages = right
Rotate = 90

########################################################################
### Insert commands to fix keystone, color, etc.
########################################################################
Pages=all
Pages = left
Crop =  1652,1344, 6197,8110 # BSW_0008 L (IMG_0007) #### the bad line!


########################################################################

Pages=all
# Rescale the image to match the final DPI
ScaleToDPI=

I even removed everything under the ### Insert commands line, and it still gave bad values.
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Need help with Crop command after Perspective command

Post by steve1066d »

Ok.. I think I know what is going on. I think you don't have "to cursor" checked.

When it isn't checked it runs the entire configuration. So it was running to ScaleToDPI command and doing the crop based on the already scaled value. Which I guess is ok, but it should have appended the configuration at the end instead of in the middle.

Actually, I'm not sure that checkbox is such a good idea... I never really uncheck it so perhaps it is a useless feature.
Steve Devore
BookScanWizard, a flexible book post-processor.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: Need help with Crop command after Perspective command

Post by rob »

Thanks, that worked. I'm going to struggle through the rest now :)
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
User avatar
rob
Posts: 773
Joined: 03 Jun 2009, 13:50
E-book readers owned: iRex iLiad, Kindle 2
Number of books owned: 4000
Country: United States
Location: Maryland, United States
Contact:

Re: Need help with Crop command after Perspective command

Post by rob »

OK, three more questions:

1. I completed adding crop boxes to both left and right pages. Now I'm at the "add registration marks" step. I added two registration marks on the left page. I went to the right page, and the registration marks were slightly above the crop box. I dragged like the instructions in the wiki said, and that moved both the crop box and the registration marks. ????

2. Is there any way to delete registration marks? When I went back to the left page, the registration marks were not where I had originally put them. I didn't want to drag, because that would end up dragging the crop box, too. ????

3. How do I deal with the fact that the book moves position slightly with each page? How about when perspective changes slightly?
The Singularity is Near. ~ http://halfbakedmaker.org ~ Follow me as I build the world's first all-mechanical steam-powered computer.
steve1066d
Posts: 296
Joined: 27 Nov 2010, 02:26
E-book readers owned: PRS-505
Number of books owned: 1250
Location: Minneapolis, MN
Contact:

Re: Need help with Crop command after Perspective command

Post by steve1066d »

The registration marks are only used to visually match things from one spot to the other. They don't actually affect any operation. I will use it to click on the title on the left side, then use it to align the box in the same spot on the right side.

There isn't any way to get rid of the registration marks, and keep the crop marks. But to get rid of all the marks press [esc].

As far as handling a page moving slightly from page to page.. you are entering the area where Scan Tailor becomes the better tool. To do it in BSW there's two options. One is to do crops for pages in groups. For example, if a crop works for the first 200 pages, you can do:

Code: Select all

Pages = left 1-200
Crop =  941,604, 1888,1557

Pages = left 201-400
Crop =  921,604, 1868,1557
Or you can use the command InterpolateCrop, which will gradually change the crop window from one spot to another.

Right now the most efficient way to handle changing crops is to uncheck the "crops" checkbox. That will show the crop lines instead of performing the crop. Then you can go forward through the book adjusting the crops. Then go back and edit the configuration so they apply to page ranges.

Perspective changes are handled the same way.

When I scan, I provide a bit extra space around the edges. Also, I normally convert it to pdf's using FineReader, which will handle a bit of rotation if the page slightly moves.

I do have some vague ideas of some enhancements for the future to allow you to grab corners and adjust things throughout the book.
Steve Devore
BookScanWizard, a flexible book post-processor.
Post Reply