diff options
author | Nick White <git@njw.name> | 2020-08-17 17:17:51 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-08-17 17:17:51 +0100 |
commit | f0363816937de806e71df80c435f13e4cd52249d (patch) | |
tree | b2e1e7eab4af4185e4d6efcc8dae0f79c70544ef | |
parent | 16965180b821e732be16b7c84396fe89efc88d48 (diff) |
Have preproc and preprocmulti commands do vertical wiping too
-rw-r--r-- | cmd/preproc/main.go | 8 | ||||
-rw-r--r-- | cmd/preprocmulti/main.go | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cmd/preproc/main.go b/cmd/preproc/main.go index e967cd2..e613e50 100644 --- a/cmd/preproc/main.go +++ b/cmd/preproc/main.go @@ -38,6 +38,9 @@ func main() { nowipe := flag.Bool("nowipe", false, "Disable wiping completely.") wipewsize := flag.Int("ws", 5, "Window size for wiping algorithm.") thresh := flag.Float64("wt", 0.05, "Threshold for the wiping algorithm to determine the proportion of black pixels below which a window is determined to be the edge.") + vmin := flag.Int("vm", 30, "Minimum percentage of the image height for the content width calculation to be considered valid.") + vthresh := flag.Float64("vt", 0.005, "Threshold for the proportion of black pixels below which a vertical wipe window is determined to be the edge. Higher means more aggressive wiping.") + vwsize := flag.Int("vw", 120, "Window size for vertical mask finding algorithm. Should be set to approximately line height + largest expected gap.") flag.Parse() if flag.NArg() < 2 { flag.Usage() @@ -66,7 +69,7 @@ func main() { } log.Print("Binarising") - var clean, threshimg image.Image + var clean, threshimg, vclean image.Image threshimg = preproc.IntegralSauvola(gray, *ksize, *binwsize) if *btype == "zeroinv" { @@ -78,7 +81,8 @@ func main() { if !*nowipe { log.Print("Wiping sides") - clean = preproc.Wipe(threshimg.(*image.Gray), *wipewsize, *thresh, *min) + vclean = preproc.VWipe(threshimg.(*image.Gray), *vwsize, *vthresh, *vmin) + clean = preproc.Wipe(vclean.(*image.Gray), *wipewsize, *thresh, *min) } else { clean = threshimg } diff --git a/cmd/preprocmulti/main.go b/cmd/preprocmulti/main.go index f5612cf..5f48c99 100644 --- a/cmd/preprocmulti/main.go +++ b/cmd/preprocmulti/main.go @@ -42,6 +42,9 @@ func main() { min := flag.Int("m", 30, "Minimum percentage of the image width for the content width calculation to be considered valid.") nowipe := flag.Bool("nowipe", false, "Disable wiping completely.") wipewsize := flag.Int("ws", 5, "Window size for wiping algorithm.") + vmin := flag.Int("vm", 30, "Minimum percentage of the image height for the content width calculation to be considered valid.") + vthresh := flag.Float64("vt", 0.005, "Threshold for the proportion of black pixels below which a vertical wipe window is determined to be the edge. Higher means more aggressive wiping.") + vwsize := flag.Int("vw", 120, "Window size for vertical mask finding algorithm. Should be set to approximately line height + largest expected gap.") flag.Parse() if flag.NArg() < 2 { flag.Usage() @@ -68,7 +71,7 @@ func main() { *binwsize++ } - var clean, threshimg image.Image + var clean, threshimg, vclean image.Image log.Print("Precalculating integral images") intImg := integral.NewImage(b) draw.Draw(intImg, b, img, b.Min, draw.Src) @@ -88,7 +91,8 @@ func main() { if !*nowipe { log.Print("Wiping sides") - clean = preproc.Wipe(threshimg.(*image.Gray), *wipewsize, k*0.02, *min) + vclean = preproc.VWipe(threshimg.(*image.Gray), *vwsize, *vthresh, *vmin) + clean = preproc.Wipe(vclean.(*image.Gray), *wipewsize, k*0.02, *min) } else { clean = threshimg } |