Skip to content

Commit 76a6f67

Browse files
committed
1.0: init
0 parents  commit 76a6f67

File tree

13 files changed

+3254
-0
lines changed

13 files changed

+3254
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/djvulibre"]
2+
path = src/djvulibre
3+
url = https://github.com/barak/djvulibre

LICENSE

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#MFBdjvu-1.0
2+
#
3+
#Based on djvulibre (http://djvu.sourceforge.net/)
4+
#Based on monday2000 (http://djvu-soft.narod.ru/)
5+
#Based on DjVu Thresholding Binarization (http://djvu-soft.narod.ru/bookscanlib/034.htm)
6+
#Based CLI of simpledjvu (https://github.com/mihaild/simpledjvu).
7+
#
8+
#MFBdjvu is distributed in the hope that it will be useful,
9+
#but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
#GNU General Public License for more details.
12+
#
13+
#You should have received a copy of the GNU General Public License
14+
#along with Simpledjvu. If not, see <http://www.gnu.org/licenses/>.
15+
16+
PROJECT = mfbdjvu
17+
DJVULIBRE_PATH = src/djvulibre
18+
CXX = g++ -O3 -std=c++0x
19+
INCLUDES = -I$(DJVULIBRE_PATH) -I$(DJVULIBRE_PATH)/libdjvu -I$(DJVULIBRE_PATH)/tools -Isrc
20+
CXXFLAGS = $(INCLUDES) -DHAVE_CONFIG_H -pthread -DTHREADMODEL=POSIXTHREADS
21+
LDFLAGS = -ldjvulibre
22+
LN = $(CXX) -DHAVE_CONFIG_H
23+
RM = rm -f
24+
25+
OBJ_FILES = src/mfbdjvu.o src/pgm2jb2.o src/jb2tune.o src/jb2cmp/libjb2cmp.a
26+
BIN_FILES = $(PROJECT)
27+
28+
all: djvulibre_config $(BIN_FILES)
29+
30+
$(PROJECT): $(OBJ_FILES)
31+
$(LN) $^ $(LDFLAGS) -o $@
32+
33+
%.o: %.cpp
34+
$(CXX) $(CXXFLAGS) -c $< -o $@
35+
36+
src/jb2cmp/libjb2cmp.a:
37+
cd src/jb2cmp && ${MAKE}
38+
39+
djvulibre_config:
40+
cd src/djvulibre && ./autogen.sh
41+
42+
clean:
43+
$(RM) $(OBJ_FILES) $(OBJ_FILE_PGM) $(BIN_FILES)
44+
cd src/jb2cmp && ${MAKE} clean

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# MFBdjvu
2+
3+
MFBdjvu is a simple project for easy converting pgm and ppm to (MASK+FG+BG)-djvu.
4+
It uses [djvulibre](http://djvu.sourceforge.net/) for all technichal work and compression.
5+
The breakdown of the image into components is done using [DjVuL](https://github.com/plzombie/depress/issues/2) and [DjVuL wiki](https://sourceforge.net/p/imthreshold/wiki/DjVuL/?version=3).
6+
7+
MFBdjvu based of [simpledjvu](https://github.com/mihaild/simpledjvu).
8+
9+
## Install
10+
11+
### load submodules
12+
13+
submodules:
14+
15+
- [djvulibre](https://github.com/barak/djvulibre) -> [src](src)
16+
17+
```shell
18+
$ git submodule init
19+
$ git submodule update
20+
```
21+
22+
### build
23+
24+
Typo:
25+
```shell
26+
$ make
27+
```
28+
29+
If you want, you can change your PATH variable or copy **mfbdjvu** binary to any directory already included in your PATH.
30+
31+
You need `g++` version supports `c++0x` standard flag.
32+
33+
## Usage
34+
35+
```shell
36+
simpledjvu [options] input.pnm output.djvu
37+
```
38+
39+
where options =
40+
41+
**-dpi n** {300} DPI output djvu.
42+
43+
**-loss n** {1} Use *n* as cjb2 loss level (see djvulibre cjb2 tool description).
44+
45+
**-slices_bg n1,n2,...** {74,89,89}. Use *n1,n2,...* as number of slices for c44 for background (see djvulibre c44 tool description).
46+
47+
**-slices_fg n1,n2,...** {89} Use *n1,n2,...* as number of slices for c44 for foreground.
48+
49+
**-levels n** {0} Level DjVuL block, 0 - auto.
50+
51+
**-bgs n** {3} Background and Foreground downsample.
52+
53+
**-fgs n** {2} Foreground more downsample.
54+
55+
**-overlay n** {50} Block overlay DjVuL in percent.
56+
57+
**-anisotropic n** {0} The main regulator DjVuL in percent. More than zero - more details, less than zero - less details.
58+
59+
**-contrast n** {0} Auxiliary regulator DjVuL in percent (sharpen).
60+
61+
**-fbs n** {100} and **-delta n** {0} Additional regulation DjVuL of BG/FG according to the linear law: FG * fgs + delta != BG
62+
63+
**-black** Using black BG as the base, not white.
64+
65+
You can use [Netpbm](https://sourceforge.net/projects/netpbm/) or any other similar tool to obtain `pgm` or `ppm` from other format.
66+
67+
## DjVuL description.
68+
69+
The [base of the algorithm](https://sourceforge.net/p/imthreshold/wiki/DjVuL/?version=3) was obtained in 2016 by studying the works [monday2000](http://djvu-soft.narod.ru/) and adapting them to Linux.
70+
The prerequisite was the [BookScanLib](http://djvu-soft.narod.ru/bookscanlib/) project and the algorithm [DjVu Thresholding Binarization](http://djvu-soft.narod.ru/bookscanlib/034.htm).
71+
This algorithm embodied good ideas, but had a recursive structure, was a "function with discontinuities" and had a hard color limit.
72+
The result of this algorithm, due to the indicated shortcomings and the absence of regulators, was doubtful.
73+
After careful study, all the foundations of the specified algorithm were rejected.
74+
The new algorithm is based on levels instead of recursion, a smooth weight function is used instead of a "discontinuous" one, no color restriction, BG/FG selection controls are enabled.
75+
The new algorithm allowed not only to obtain a much more adequate result, but also gave derivative functions: image division into BG/FG according to the existing mask.

0 commit comments

Comments
 (0)