Skip to content

Update for opencv4 #5

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
binarizewolfjolion
result_*.jpg
20 changes: 9 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@


all:
g++ -I/usr/include/opencv binarizewolfjolion.cpp -o binarizewolfjolion `pkg-config opencv --libs` -lstdc++
c++ -O2 -I/usr/include/opencv4 binarizewolfjolion.cpp -o binarizewolfjolion `pkg-config opencv4 --libs` -lstdc++

test: all
./binarizewolfjolion -k '-0.2' -m 'n' sample.jpg result_n.jpg
./binarizewolfjolion -k '0.6' -m 's' sample.jpg result_s.jpg
./binarizewolfjolion -k '0.6' -m 'w' sample.jpg result_w.jpg

clean:
rm -f binarizewolfjolion
rm -f result_*.jpg

test:
./binarizewolfjolion -k 0.6 sample.jpg _result.jpg


package: clean
rm -f x.jpg
tar cvfz binarizewolfjolionopencv.tgz *

package: clean
tar -cvfz binarizewolfjolionopencv.tar.gz *
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,17 @@ This code uses an improved contrast maximization version of Niblack/Sauvola et a

## Usage:

The executable is called on the command line and only reads and writes PGM files. Under Linux you can use for instance "convert" (part of the ImageMagick package) to convert to and from the PGM format. The first argument chooses between one of several methods, the first and the second argument specify, respectively, the input and the output file:

```
usage: binarize [ -x -y -k ] [ version ]

version: n Niblack (1986) needs white text on black background
s Sauvola et al. (1997) needs black text on white background
w Wolf et al. (2001) needs black text on white background
Usage: ./binarizewolfjolion [ -x <winx> -y <winy> -k <parameter> -m <method> ] <inputimage> <outputimage>

Default version: w (Wolf et al. 2001)
Default value for "k": 0.5
method: n Niblack (1986) needs white text on black background
s Sauvola et al. (1997) needs black text on white background
w (deafult) Wolf et al. (2001) needs black text on white background

example:
binarize w in.pgm out.pgm
binarize in.pgm out.pgm
binarize s -x 50 -y 50 -k 0.6 in.pgm out.pgm
Example:
./binarizewolfjolion -m w in.pgm out.pgm
./binarizewolfjolion in.pgm out.pgm
./binarizewolfjolion -m s -x 50 -y 50 -k 0.6 in.pgm out.pgm
```

The best working method is 'w', the one which performed 5th in the [DIBCO 2009 competition](http://www.cvc.uab.es/icdar2009/papers/3725b375.pdf).
Expand Down
Loading