/binarizewolfjolion

Document image binarization for Project 3A @Mines_Nancy

Primary LanguageC++OtherNOASSERTION

Document Image Binarization and Analysis with FCA tools

FCA resources

Project content

Recent theoretical work seems to indicate there can be no absolute benchmark to measure quality and performance of automated interpretation algorithms Machine Perception (speech recognition, computer vision, ...). We therefore propose to investigate formal data mining techniques to try and measure levels of agreement and disagreement between various algorithms. Our application domain will be in the area of Document Image Analysis.

We have different algorithms trying to solve the same given interpretation problem. Although they are supposed to solve the same problem, they will not necessarily obtain the same results in all the input data. We will try and categorize the levels of agreement and disagreement between algorithms.

Expressed more formally, each algorithm instance takes its input data in the same data space (usually the images of graphic documents) and expresses an interpretation according to its own semantic context. We will use Formal Concept Analysis [1] to characterize these different contexts, identify areas of semantic overlap and areas of polysemy.

Binarization Algorithm

Four algorithms are used:

  • Simple binarization algorithm
  • Niblack
  • Sauvola et al.
  • Wolf et al.

There are two parts in this repo. The first part is written in python, which enable a simple binarization algorithm.

The second part uses an improved contrast maximization version of Niblack/Sauvola et al's method to binarize document images. It is also able to perform the more classical Niblack as well as Sauvola et al. methods. Details can be found in the ICPR 2002 paper.

example

More example can be found in my blog:

http://zpjiang.me/2013/10/04/document-binarization/

Usage

Preface

The binary executable file src/binarizewolfjolion dose not work in Mac OS, as it is compiled in linux. It is suggested that run this project on Linux. Of course it dose work if all wolfjolion algorithms codes are recompiled in Mac.

Prerequisite

  • Java: for the execution of Galicia and Lattice Miner
  • Python: for the execution of script, for example, generating image
  • PIL: Python Image Library, for image generating
  • gcc/g++: for the execution of three binarization algorithms

Folders

fca/ : Input and output file of formal concept analyse img_bin/ : Binary image generated by binarization algorithm img_src/ : Source images to test res_gt/ : Resouce of Ground Truth src/ : All source code tools/ : Execution file of Lattice Miner, Galicia, Fcbo run.sh : Main execution commands LICENSE : License file README.md : Readme file

Execute step by step

	############
	#
	# Don't run this script directly!
	# As there is two branches, for Galicia and Fcbo.
	#
	############



	############
	# Preparation of images

	# Generate ppm with simple binarization algorithm
	# python [source code] [input image] [output image]
	python src/binarizezhipeng.py img_src/test.jpg img_bin/test_p.ppm

	# Generate ppm with algorithm of Niblack (1986)
	# ./[source code] [option of algorithm] [input image] [output image]
	./src/binarizewolfjolion n img_src/test.jpg img_bin/test_n.ppm

	# Generate ppm with algorithm of Wolf et al. (2001)
	# ./[source code] [option of algorithm] [input image] [output image]
	./src/binarizewolfjolion w img_src/test.jpg img_bin/test_w.ppm

	# Generate ppm with algorithm of Sauvola et al. (1997)
	# ./[source code] [option of algorithm] [input image] [output image]
	./src/binarizewolfjolion s img_src/test.jpg img_bin/test_s.ppm



	############
	# Next there are two branches, one is for Galicia, one is for Fcbo.
	############


	############
	# Galicia

	# construct format input for Galicia, etc.
	# python [source code] [input image 1] [input image 2] [input image 3] [input image 4]
	python src/generateTableGalica.py img_bin/test_p.ppm img_bin/test_w.ppm img_bin/test_n.ppm img_bin/test_s.ppm

	# After this step, testBin.slf will be generated in fca/, this is the input file for Calicia. 
	# Once imported into Galicia, save lattice image as lattice.lat.xml. 

	# Generate different images according to different lattice concepts
	# python [source code] [lattice data]
	python src/generateImage.py fca/lattice.lat.xml



	############
	# Fcbo

	# construct format input for Fcbo.
	# python [source code] [input image 1] [input image 2] [input image 3] [input image 4]
	# After this step, testBinFcbo.dat will be generated in fca/, this is the input file for Fcbo. 
	python src/generateTableFcbo.py img_bin/test_p.ppm img_bin/test_w.ppm img_bin/test_n.ppm img_bin/test_s.ppm

	# Generate result data with Fcbo
	# ./[source code] [input data] [output data]
	./tools/fcbo-ins/fcbo fca/InputDataFcbo.dat fca/resFcbo.dat 



	############
	# Fcbo + GT(Ground Truth)

	# construct format input for Fcbo
	# python [source code] [folder name of csv files]
	# After this step, InputDataFcboGT[1-10].dat will be generated in fca/, this is the input file for Fcbo.
	python src/generateTableFcboGT.py res_gt/

	# Generate result data with Fcbo
	# ./[source code] [input data] [output data]
	./tools/fcbo-ins/fcbo fca/InputDataFcboGT1.dat fca/resFcbo1.dat
	./tools/fcbo-ins/fcbo fca/InputDataFcboGT2.dat fca/resFcbo2.dat
	./tools/fcbo-ins/fcbo fca/InputDataFcboGT3.dat fca/resFcbo3.dat
	# ...

Limitations (To be completed)

  1. Input scale is not large enough for the image analysis. reference: http://biblio.info.ucl.ac.be/2004/285670.pdf

Licence

Permission is granted for anyone to copy, use, modify, or distribute this program and accompanying programs and documents for any purpose, provided this copyright notice is retained and prominently displayed, along with a note saying that the original programs are available from my web page.

The programs and documents are distributed without any warranty, express or implied. As the programs were written for research purposes only, they have not been tested to the degree that would be advisable in any important application.

All use of these programs is entirely at the user's own risk.