Skip to content
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

Take the background color from the input image #39

Open
galfar opened this issue Nov 15, 2020 · 8 comments
Open

Take the background color from the input image #39

galfar opened this issue Nov 15, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@galfar
Copy link
Owner

galfar commented Nov 15, 2020

Request came in to extend "-b" background color parameter to take it's value from the input image (edge/corner).
https://galfar.vevb.net/wp/projects/deskew/comment-page-2/#comment-184847

One request if at all possible is can there be an option for -b that auto samples the rgb value of an edge. I currently run an auto-crop script after they are deskewed and some pages have a different background color. This sometimes trips up the auto crop into thinking the added background is an edge. I’m hoping for something a little more dynamic that allows me to use the tool without sorting the material first.

Hi, you mean something like “look at pixel [0,0] of input image and use it for output background”?

Yes. “look at pixel [0,0] of input image and use it for output background” would be a great additional feature.

@galfar galfar added the enhancement New feature or request label Nov 15, 2020
@GitHubRulesOK
Copy link

Many scanned images have lots of noise at the edges so a one pixel test could produce the inverse of expectation, what may be better is a user defined sample zone (say N x N e.g. N<=8 pixels for averaging) and a variable location such as X,Y that could be from 0,0 up to image max X-N,Y-N.

@galfar
Copy link
Owner Author

galfar commented Jun 8, 2021

Good remark, just maybe the passing of all this over the command line might be a bit clunky.

  • "-b 80efefef" current passing of fixed color
  • "-b s4@rt" sample 4x4 area at right top corner
  • "-b s8@366,273" sample 8x8 area at specific location

@GitHubRulesOK
Copy link

GitHubRulesOK commented Jun 8, 2021

Last one looks ok to me if documented well enough

  • is the S needed
  • @ could trip some platform/upstream app parsing
  • is -b 8,366,273 good enough for detection within ,limits, or use a different -char ?

@galfar
Copy link
Owner Author

galfar commented Jun 8, 2021

I would keep "-b" so there's more free letters for new features :)
Could be that the background "mode" is determined by number of commas in the value:
"-b ff00ff" -> no comma, value is a hex color
"-b 8,rt" -> one comma, sample at one of the four corners
"-b 8,366,273" two commas, sample at specific location

@GitHubRulesOK
Copy link

Look fine, Looking forward to a release and closure just a Small Matter Of Programming :big grin:

@galfar
Copy link
Owner Author

galfar commented Sep 3, 2021

I've been doing some experiments with "local" background fill color ("extending the sides of the page") where the fill is not of uniform color everywhere and looks better in case like (often seen) one side of the scanned page is lighter/darker than the other one.

@GitHubRulesOK
Copy link

GitHubRulesOK commented Sep 3, 2021

@galfar no sure if your "not of uniform" is reference to if the scan is "faded/bleached" one side or the background is "graduated/gradient" you start getting into double threshold values where colour range becomes more difficult such that gui rgb histograms become a more complex step/need

However a "range" can be collected by using a long margin strip either "side to side" or "top to bottom" or a user defined second sample box.

@galfar
Copy link
Owner Author

galfar commented Sep 3, 2021

Your "margin strip" describes it better. Some heavy blur or other method is needed on the repeated strip however to hide the tiling artifacts.
Anyway, this could be an additional background method to fixed color and sample box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants