New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize Content Size #89

Open
Mohib2 opened this Issue Apr 7, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@Mohib2

Mohib2 commented Apr 7, 2014

One very, very useful improvement would be a new step between steps 4 (Select content) and 5 (Margins) which I would call "4A - Content size normalization".

What you do, is select a typical page of text, and the width of that content becomes the baseline. You then say "apply to all pages", "selected pages", etc. to scale the other pages' content so the width matches the baseline page, and then the margins are applied.

This way problems with varying page sizes on images -- and hence content size (i.e. text is not uniform size on every page), due to camera-book distance drift as you go through a thick book (a problem I and other simpler scanner designs have as the page surface to camera distance is not fixed as compared to more sophisticated v-platen designs) can be eliminated during post processing and the content -- i.e. text size, and line lengths -- will have uniform size.

Right now because I do all right pages, then spin the book around and do all left page (starting at the back end of the book, so page turning is easy and the same as "normal reading"), so the last page from the right hand set is "small" as it's furthest away from the camera, but it's facing, left page is "large" because that's done as the first page when doing the left hand pages as I start at the end of the book, so when flipping pages in the PDF the text alternates between large and small.

I'm sure there are other details that need to be thought through -- or even better methods, but that's the basic idea.

@ncraun ncraun added the enhancement label Apr 7, 2014

@Mohib2

This comment has been minimized.

Show comment
Hide comment
@Mohib2

Mohib2 Apr 17, 2014

Further to my explanation in the initial request on this issue, I have posted some details and a sample of the problem at the following link:
http://www.diybookscanner.org/forum/viewtopic.php?f=14&t=3007#p17556

And some rational behind why it would be a good issue to solve via software here:
http://www.diybookscanner.org/forum/viewtopic.php?f=14&t=3007&start=10#p17586

As to the solutions, upon thinking further about the 2 methods for this I suggested I have the following thoughts them.

METHOD 1

Pick the first and last pages (assuming they are the largest and smallest) from one side of the book, calculate the difference and determine the adjustment factor to apply to every page.

Problems that can make this unreliable are:

  1. Every page in the book may not have been scanned and so there would be gaps and that means the distribution of the adjustment factor would not be continuous and the method would fail.

  2. Determining the difference in width between first and last page's content would need accurate identification of the page boundary. If it is done by content, then this might need to be adjusted to ensure only the 'standard' content width on each page (i.e. the text) is used and the content width is not 'fooled' by pictures that bleed to the edge of the page. In which case, if this functionality is developed, then it makes more sense to use Method 2 which is more reliable, where this functionality would be needed anyway as it's main requirement.

METHOD 2

You select a page that you'd like to be the baseline from which the the 'standard' content to be measured is identified (this will typically be the text width) and then every page (or selected pages, etc.) this 'standard' content area is identified, and it's width scaled to match the width of the 'standard' content on the baseline page (in width because height may vary as content may not fill the page).

Problems with this method are:

  1. Content selected may not be representative of the 'baseline' content by which the scale adjustment factor is to be calculated due to pictures bleeding to the edge of the page.

Advantages of this method are:

  1. Every page is calculated independently and so gaps in the page sequence, which cause jumps in the scale factor are not an issue (as with method 1).

  2. If a simple method to tune the width of 'standard' content selected on a given page is provided (like the way the content area can be adjusted on a page by page basis in step 4) so the content selected for the scaling calculation can be adjusted to match the baseline content, errors can be corrected on a page by page basis as ScanTailor currently allows for all it's functions.

  3. A simple way to identify which pages have got incorrect scaling -- because auto selection didn't identify the 'standard' content correctly -- would be provide a 'sort by scale factor' view for the thumbnails (as ScanTailor does for other steps) and so the process to find anomalies and outliers would be the same as is done now -- check the pages with the largest and smallest scale factors to ensure and/or fix pages where the 'standard' content was not correctly identified and resulted in a scale factor that's unusually large or small.

Mohib2 commented Apr 17, 2014

Further to my explanation in the initial request on this issue, I have posted some details and a sample of the problem at the following link:
http://www.diybookscanner.org/forum/viewtopic.php?f=14&t=3007#p17556

And some rational behind why it would be a good issue to solve via software here:
http://www.diybookscanner.org/forum/viewtopic.php?f=14&t=3007&start=10#p17586

As to the solutions, upon thinking further about the 2 methods for this I suggested I have the following thoughts them.

METHOD 1

Pick the first and last pages (assuming they are the largest and smallest) from one side of the book, calculate the difference and determine the adjustment factor to apply to every page.

Problems that can make this unreliable are:

  1. Every page in the book may not have been scanned and so there would be gaps and that means the distribution of the adjustment factor would not be continuous and the method would fail.

  2. Determining the difference in width between first and last page's content would need accurate identification of the page boundary. If it is done by content, then this might need to be adjusted to ensure only the 'standard' content width on each page (i.e. the text) is used and the content width is not 'fooled' by pictures that bleed to the edge of the page. In which case, if this functionality is developed, then it makes more sense to use Method 2 which is more reliable, where this functionality would be needed anyway as it's main requirement.

METHOD 2

You select a page that you'd like to be the baseline from which the the 'standard' content to be measured is identified (this will typically be the text width) and then every page (or selected pages, etc.) this 'standard' content area is identified, and it's width scaled to match the width of the 'standard' content on the baseline page (in width because height may vary as content may not fill the page).

Problems with this method are:

  1. Content selected may not be representative of the 'baseline' content by which the scale adjustment factor is to be calculated due to pictures bleeding to the edge of the page.

Advantages of this method are:

  1. Every page is calculated independently and so gaps in the page sequence, which cause jumps in the scale factor are not an issue (as with method 1).

  2. If a simple method to tune the width of 'standard' content selected on a given page is provided (like the way the content area can be adjusted on a page by page basis in step 4) so the content selected for the scaling calculation can be adjusted to match the baseline content, errors can be corrected on a page by page basis as ScanTailor currently allows for all it's functions.

  3. A simple way to identify which pages have got incorrect scaling -- because auto selection didn't identify the 'standard' content correctly -- would be provide a 'sort by scale factor' view for the thumbnails (as ScanTailor does for other steps) and so the process to find anomalies and outliers would be the same as is done now -- check the pages with the largest and smallest scale factors to ensure and/or fix pages where the 'standard' content was not correctly identified and resulted in a scale factor that's unusually large or small.

@atla5 atla5 added the new label Sep 18, 2016

@Mohib2

This comment has been minimized.

Show comment
Hide comment
@Mohib2

Mohib2 Mar 30, 2017

I was thinking a simpler, very easy way to solve this problem would be to use a calibration sheet (say a 1" checker board) that can be easily de-skewed and analysed. So that would be scanned it first (placing it on top of the first page of the book) and again last, (placing it on top of the last page after scanning the book) and the size difference of the squares (by number of pixels) between the first and last image would give the image scale change which can then be applied across all pages proportionately.

It might not even need a special calibration pattern, but just a sheet with some bold pattern -- that Scan Tailor can consistent and accurately content select -- that is just scanned as both the first and last page. Then, if there was an option in step 5 (so after the auto-content selection of step 4) to say first and last images are calibration pages, the scale factor can be determined -- by comparing the number of pixels (width or height) the auto-content selection found for the two calibration images -- and applied as part of the margin application process (since there is already scaling being done when they are applied).

Mohib2 commented Mar 30, 2017

I was thinking a simpler, very easy way to solve this problem would be to use a calibration sheet (say a 1" checker board) that can be easily de-skewed and analysed. So that would be scanned it first (placing it on top of the first page of the book) and again last, (placing it on top of the last page after scanning the book) and the size difference of the squares (by number of pixels) between the first and last image would give the image scale change which can then be applied across all pages proportionately.

It might not even need a special calibration pattern, but just a sheet with some bold pattern -- that Scan Tailor can consistent and accurately content select -- that is just scanned as both the first and last page. Then, if there was an option in step 5 (so after the auto-content selection of step 4) to say first and last images are calibration pages, the scale factor can be determined -- by comparing the number of pixels (width or height) the auto-content selection found for the two calibration images -- and applied as part of the margin application process (since there is already scaling being done when they are applied).

@Mohib2

This comment has been minimized.

Show comment
Hide comment
@Mohib2

Mohib2 Mar 30, 2017

As an update to my last comment about using a calibration page, the scale adjustment factor has to be applied differently, depending on whether 1 or 2 cameras were used for the scanning. So there would need to be an additional option to say if calibration pages were for 1 or two cameras.

  • For a 1 camera setup (like mine), if there were 100 pages scanned, then pages 1, 3, 5, etc start big and go smaller, while pages 2, 4, 6, etc. start small and go bigger (because even pages are scanned in reverse with the book upside down). So for odd pages the images have to be gradually scaled bigger (start with no scaling on page 1, and maximum scaling for the last page 99). But for even pages, the images have to the scale applied in reverse, so maximum scaling on page 2 and no scaling on page 100.

  • For a 2 camera setup, a start and end calibration page should be used for each camera (just in case camera-platen distance is no the same for left and right pages). So there would be two calibration pages at the start (one for the left and one for the right camera) and two at the end, and two scale factors. Since with two cameras both left and right are scanned at the same time and in the same direction, then the scaling for all pages would be done starting with no scaling for the first page and maximum scaling on the last page, but using the left scale factor on the left pages and the right scale factor on the right pages.

Mohib2 commented Mar 30, 2017

As an update to my last comment about using a calibration page, the scale adjustment factor has to be applied differently, depending on whether 1 or 2 cameras were used for the scanning. So there would need to be an additional option to say if calibration pages were for 1 or two cameras.

  • For a 1 camera setup (like mine), if there were 100 pages scanned, then pages 1, 3, 5, etc start big and go smaller, while pages 2, 4, 6, etc. start small and go bigger (because even pages are scanned in reverse with the book upside down). So for odd pages the images have to be gradually scaled bigger (start with no scaling on page 1, and maximum scaling for the last page 99). But for even pages, the images have to the scale applied in reverse, so maximum scaling on page 2 and no scaling on page 100.

  • For a 2 camera setup, a start and end calibration page should be used for each camera (just in case camera-platen distance is no the same for left and right pages). So there would be two calibration pages at the start (one for the left and one for the right camera) and two at the end, and two scale factors. Since with two cameras both left and right are scanned at the same time and in the same direction, then the scaling for all pages would be done starting with no scaling for the first page and maximum scaling on the last page, but using the left scale factor on the left pages and the right scale factor on the right pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment