Análisis interactivo de diseño de páginas manuscritas
Abstract
[EN] The amounts of ancient documents transcribed by means of HTR technology have been rising dramatically over the last years. Consequently, the development and enhancement of HTR methods and algorithms have been rising as well. However, Layout Analysis remains a bottleneck in the development and generalization of HTR technology. In this work we present a new Interactive-Probabilistic method that incorporates the user feedback in the Layout Analysis process, in order to provide not only a very accurate layout, but an interactive framework in which user feedback is used to help the user to fix any error.
Full text
UNIVERSITAT POLITÈCNICA DE VALÈNCIA DEPARTAMENTO DE SISTEMAS INFORMÁTICOS Y COMPUTACIÓN PATTERN RECOGNITION AND HUMAN LANGUAGE TECHNOLOGY GROUP IARFID Master Thesis Interactive Layout Analysis Author: Lorenzo Quirós Díaz Advisor: Carlos D. Martínez Hinarejos Co-advisor: Alejandro Héctor Toselli September 19, 2016
Abstract The amounts of ancient documents transcribed by means of HTR technology have been rising dramatically over the last years. Consequently, the development and enhancement of HTR methods and algorithms have been rising as well. However, Layout Analysis remains a bottleneck in the development and generalization of HTR technology. In this work we present a new Interactive-Probabilistic method that incorporates the user feedback in the Layout Analysis process, in order to provide not only a very accurate layout, but an interactive framework in which user feedback is used to help the user to fix any error. Resumen La cantidad de documentos antiguos transcritos por medio de la tecnología HTR se ha incrementado drásticamente en los últimos años. En consecuencia, el desarrollo y la mejora de los métodos y algoritmos de HTR también han aumentado. Sin embargo, Layout Analysis sigue siendo un cuello de botella en el desarrollo y la generalización de la tecnología de HTR. En este trabajo se presenta un nuevo método Interactivo-Probabilístico que incorpora la realimentación del usuario en el proceso de Layout Analysis, con el fin de proporcionar, no sólo un diseño muy preciso, sino un marco interactivo en el que se utiliza la realimentación de los usuarios para ayudar al usuario a corregir cualquier error. Resum La quantitat de documents antics transcrits per mitjà de la tecnologia HTR s’ha incrementat dràsticament als últims anys. Açò ha provocat que el desenvolupament i la millora dels mètodes i algoritmes d’HTR hagen augmentat també. Però el Layout Analysis continua sent el coll d’ampolla del desenvolupament i la generalització de la tecnologia HTR. Aquest treball presenta un nou mètode Interactiu-Probabilístic que incorpora la retroalimentació de l’usuari al procés de Layout Analysis amb la finalitat de proporcionar no només un disseny molt precís, sinó un marc interactiu al que s’utilitza la realimentació dels usuaris per a ajudar a l’usuari a corregir qualsevol error. iii
ACKNOWLEDGEMENTS Many people have helped me to complete this work. Thanks to my family and friends for the support and for making this venture more enjoyable, specially to María Vidal and Adolfo Méndez for their reviews and advice. Finally this work have not been completed without the knowledge and advice of Enrique Vidal, Alejandro Héctor Toselli and Carlos D. Martínez, I am very grateful for their time and patience during this journey. v
TODO LIST Lorenzo Quirós Díaz Interactive Layout Analysis
CONTENTS 1 Introduction 1 1.1 Introduction ......................... 2 1.2 Motivation .......................... 3 1.3 Related Work ........................ 3 1.4 Overview of the Proposal Approach ............ 4 1.5 Context of Applications and Assumptions ......... 5 1.6 Expected Outcomes/Results ................ 6 Bibliography ........................... 6 2 Fundaments 9 2.1 Principal Components Analysis ............... 10 2.2 Conditional Random Fields ................. 10 2.3 Gaussian Mixture Models .................. 11 2.4 Interactive Pattern Recognition ............... 12 2.4.1 Definition ...................... 12 2.4.2 Using the Human Feedback Directly ........ 13 2.4.3 Taking interaction history into account ....... 13 2.4.4 Interaction with Deterministic Feedback ...... 13 2.5 Evaluation Measures .................... 14 2.5.1 Pixel-wise performance .............. 14 2.5.2 MatchScore ..................... 15 2.5.3 Goal-Oriented Success Rate ............ 15 Bibliography ........................... 16 3 Interactive Layout Analysis 19 3.1 Interactive Layout Analysis ................. 20 3.1.1 Layout Analysis Problem .............. 21 3.1.2 Interactive Framework ............... 23 3.2 System Architecture ..................... 23 3.3 Pre-processing ........................ 24 3.4 Feature Extraction ...................... 24 3.5 CRF’s Learning ....................... 27 3.6 GMM Learning ....................... 28 3.7 User Interaction ....................... 29 Lorenzo Quirós Díaz Interactive Layout Analysis
Chapter 1. Introduction 1.1 Introduction Handwritten Text Recognition can be defined as the problem of finding the most likely word sequence for a given handwritten sequence image [13]. Under this definition, the presence of an input image is needed, but this image should contain only a handwritten sequence; this meas that only one "line" of handwritten text is processed at once. Now, since main goal of HTR systems is to translate not just a single line, but the complete page or even the complete book, a previous system is needed in order to extract those lines from the whole page and, in an upper level, to extract the different zones of the page (paragraph, marginal notes, illustrations, page number, etc.). Notice that, this is a very important step of the HTR process; for example, if we develop a system to recognize text in an image, but we provide an illustration without text, the results of that system are expected to be erroneous. In the best case system is capable of ignore that kind of inputs, but we waste time and computing resources on it. In addition, knowledge of the type of zone is very useful to provide some context to the text in the zone, and since each zone can be semantically different, each zone can be processed differently. Document Layout analysis (DLA) is the process of identifying and categorizing the regions of interest in an image of a document. Commonly this process is divided in two sub problems [6]: detection and labeling of the different zones in the image (body, illustrations, marginalia) is called geometric layout analysis, and the classification of these zones into their logical role (title, caption, footnote, etc.) is called the logical layout analysis. Several methods have been developed for DLA [1–3,5,9,16,18], most of them based on Computer Vision techniques, such as, binarization [11,14], skew correction [10,12,15] and Connected Components labeling [4,8], among others. All of these methods are designed for an user-free system, as a consequence, any error on the system result must be fixed from scratch by the user. In this work, an Interactive-Probabilistic approach for image layout analysis is proposed, with the aim of providing, not only a very accurate layout, but an interactive framework in which user feedback is used to fix any error. Conditional Random Fields models have been combined with a prior-probability model and Interactive Pattern Recognition [17] to build the new method. 2
1.2. Motivation This document is organized as follows: In the first chapter we introduce the topic under study, and cover the motivation and our approach. In Chapter 2we cover technical fundaments of our approach along with evaluation measures. Our approach is explained in detail in Chapter 3. Then, experiments and results that help us evaluate the proposed method are presented and discussed in Chapter 4. Finally, in Chapter 5we present the conclusions extracted from our research, and future work to be covered. 1.2 Motivation Several manuscripts have been digitized in order to preserve the valuable information from the day-by-day deterioration of the physical document. The amount and importance of the information contained in these manuscripts motivates the development of several techniques and tools to explore, analyze, and read them in a more comprehensive manner. These technologies and tools cover from image quality enhancement to automatic Handwritten Text Recognition (HTR). One of the most crucial steps in HTR is Document Layout Analysis. This is the process in which zones of interest in a page image are detected and categorized. This process is commonly performed by hand, and sometimes assisted by semi-automatic methods [7,16,19] (semi-automatic because the final user always needs to review the results). With the premise that the user always needs to reviewathe results, and assuming the importance of the DLA in HTR systems, it is highly desirable to study interactive methods to improve the aforementioned systems. 1.3 Related Work Several methods have been developed on the last few years to extract the correct Layout from digitized pages. Most of them [1–3,5,9,16,18] follow a similar set of steps: aAt the time this paper is written state-of-the-art methods are far away to achieve a completely automatic system. 3
Chapter 1. Introduction (i) Image binarization. (ii) Skew correction. (iii) Connected Components and/or White spaces analysis. (iv) Some heuristic to link/merge blocks found in the previous step. (v) Clean the result (filter out small blocks, remove unsuitable blocks, etc.). Furthermore, in all of the methods studied, a binarization step is performed, which is a very hard problem by itself. This causes an increment in the difficulty of the original problem and a direct dependence from the binarization method. Also, used heuristics limit the generalization of the methods, since several parameters needs to be tuned by the user based on the features of the input images (page degradation, number of columns, illustrations, quality of the scan, etc.). 1.4 Overview of the Proposal Approach As mentioned above, methods proposed until now still have errors. Thus, the user needs to go trough all the images in order to review if the layout proposed by the classification method is correct or not; then, if there is any error, the user must fix it. In this work we propose to use a probabilistic methodology to provide not only a good layout but to help the user to easily fix any error provided by the classifier. Under this context, we use the Interactive Pattern Recognition (IPR) framework proposed by Toselli et al. [17] to solve this issue presented in Layout Analysis. The IPR framework forces, from its definition, to use a probabilistic model in order to take advantage of the information inside the model and the information provided by the user iteratively. Therefore, we do not need just a classification of the zones of the page (i.e. a single hypothesis provided by the classifier), but, the probability of each possible hypothesis, where each hypothesis represents a possible layout under the page restrictions. Of course, this normally means a huge search space, even on a simple small image. In order to guide search algorithms to the best hypothesis, a prior-probability distribution over the limits of the zones should be learned form training data. Assuming that zones are rectangles, 4
1.5. Context of Applications and Assumptions limits can be defined by upper-left and bottom-right corners; therefore, prior-probability on these two corners is estimated. We use Conditional Random Fields to model the conditional distribution of the image pixels in each layout zone (p(hk|xij)b) and to provide the main probability distribution to the IPR framework. Also, multi-variable Gaussian mixture models are used to learn the prior-probability distribution of the corners of each zone in the layout. Finally, a brute force approach is taken to search best hypothesis under the probabilistic model and the user feedback. 1.5 Context of Applications and Assumptions Many enhancements and test cases should be done on the proposed system before reaching stable version of it. For this reason, this project will be divided into some stages to fulfill quality and time restrictions; in this work we will present a the first step, which is restricted by the following constrains for experimentation: •Experiments will be conducted over a small set of images. •Experiments will be limited to only search for the main paragraph in the pages. •Page images are assumed to have only a main paragraph, marginalia, titles, catch-words, and other types of zones, but not illustrations or figures. These constrains are appropriate to present the method without loss of generality, because all the theory behind it is not limited by the constrains, but just by the experimentation. bSee Section 3.1 for a detailed description of the notation 5
Bibliography 1.6 Expected Outcomes/Results The expected results are: •A formal definition of the new probabilistic method, based on CRFs, GMMs and the IPR framework. •Evaluation of the performance of proposed method, based on state- of-the-art evaluation methodologies. •A review of the impact of the new approach in the final user effort. •A demo to present new method features. •A solid base for future project steps. Bibliography [1] Antonacopoulos, A., Clausner, C., Papadopoulos, C., and Pletschacher, S. (2011). Historical document layout analysis competition. Proceedings of the International Conference on Document Analysis and Recognition, ICDAR, pages 1516–1520. [2] Antonacopoulos, A., Clausner, C., Papadopoulos, C., and Pletschacher, S. (2013). ICDAR 2013 competition on historical book recognition (HBR 2013). Proceedings of the International Conference on Document Analysis and Recognition, ICDAR, pages 1459–1463. [3] Antonacopoulos, A., Clausner, C., Papadopoulos, C., and Pletschacher, S. (2015). 2015_ICDAR2015 Competition on Recognition of Documents with Complex Layouts -RDCL2015. In Document Analysis and Recognition (ICDAR), 2015 13th International Conference on, pages 1151–1155. [4] Bieniek, A. and Moga, A. (2000). An efficient watershed algorithm based on connected components. Pattern Recognition, 33(6):907–916. [5] Bukhari, S. S., Breuel, T. M., Asi, A., and El-Sana, J. (2012). Layout analysis for Arabic historical document images using machine learning. Proceedings - International Workshop on Frontiers in Handwriting Recognition, IWFHR, pages 639–644. 6
Bibliography [6] Cattoni, R., Coianiz, T., Messelodi, S., and Modena, C. M. (1998). Geometric layout analysis techniques for document image understanding: a review. Technical report. [7] Gatos, B., Stamatopoulos, N., and Louloudis, G. (2011). ICDAR2009 handwriting segmentation contest. International Journal on Document Analysis and Recognition, 14(1):25–33. [8] Grana, C., Borghesani, D., and Cucchiara, R. (2010). Optimized block-based connected components labeling with decision trees. IEEE Transactions on Image Processing, 19(6):1596–1609. [9] Lazzara, G., Geraud, T., and Levillain, R. (2014). Planting, growing, and pruning trees: Connected filters applied to document image analysis. Proceedings - 11th IAPR International Workshop on Document Analysis Systems, DAS 2014, pages 36–40. [10] Liu, H., Wu, Q., Zha, H., and Liu, X. (2008). Skew detection for complex document images using robust borderlines in both text and non-text regions. Pattern Recognition Letters, 29(13):1893–1900. [11] Niblack, W. (1985). An Introduction to Digital Image Processing. Strandberg Publishing Company. [12] Papandreou, A., Gatos, B., Louloudis, G., and Stamatopoulos, N. (2013). ICDAR 2013 document image skew estimation contest (DISEC 2013). Proceedings of the International Conference on Document Analysis and Recognition, ICDAR, pages 1444–1448. [13] Romero, V., Serrano, N., Toselli, A. H., Sánchez, J. A., and Vidal, E. (2011). Handwritten Text Recognition for Historical Documents. Language Technologies for Digital Humanities and Cultural Heritage, (September):90–96. [14] Sauvola, J. and Pietikäinen, M. (2000). Adaptive document image binarization. Pattern Recognition, 33(2):225–236. [15] Singh, C., Bhatia, N., and Kaur, A. (2008). Hough transform based fast skew detection and accurate skew correction methods. Pattern Recognition, 41(12):3528–3546. [16] Smith, R. (2009). Hybrid Page Layout Analysis via Tab-Stop Detection. In Proceedings of the 2009 10th International Conference on Document Analysis and Recognition, pages 241–245. IEEE Computer Society. 7
Bibliography [17] Toselli, A. H., Vidal, E., and Casacuberta, F. (2011). Multimodal Interactive Pattern Recognition and Applications. Springer. [18] Vil’kin, A. M., Safonov, I. V., and Egorova, M. A. (2013). Algorithm for Segmentation of Documents Based on Texture Features. Pattern Recognit. Image Anal., 23(March, 2013):153–159. [19] Wang, S. Y., Baird, H. S., and An, C. (2009). Document content extraction using automatically discovered features. Proceedings of the International Conference on Document Analysis and Recognition, ICDAR, pages 1076–1080. 8
CHAPTER 2 FUNDAMENTS Chapter Outline 2.1 Principal Components Analysis ........... 10 2.2 Conditional Random Fields ............. 10 2.3 Gaussian Mixture Models .............. 11 2.4 Interactive Pattern Recognition .......... 12 2.5 Evaluation Measures ................ 14 Bibliography ........................ 16 Lorenzo Quirós Díaz Interactive Layout Analysis
Chapter 2. Fundaments the proposed method is founded on several other methods and algorithms. In this chapter a short overview of those methods and algorithms is presented. Also, some evaluation measures are presented in order to define experiments evaluation criteria. 2.1 Principal Components Analysis Principal Components Analysis is probably the most known non-supervised technique used to reduce the dimensionality of a data set. Although, PCA does not discriminate between classes, it is very used because most information in the data is preserved after reduction [3]. PCA main goal is to find a projection matrix W, which minimizes the reconstruction error. The solution of this problem is well know [18] and it is to chose those eigenvectors of the covariance matrix, whose eigenvalues are the highest ones; then, the first keigenvectors, with highest eigenvalues, are used to compose the projection matrix W. The algorithm can be summarized in the following steps: 1. Compute the mean of the data. 2. Subtract the mean to all data. 3. Calculate the covariance matrix on data. 4. Calculate the eigenvectors and eigenvalues of the covariance matrix, ordered by highest eigenvalues. 5. Define projection matrix Wby the first keigenvectors. For a detailed explanation about how PCA works, please refer to [3,18] 2.2 Conditional Random Fields In the case of image labeling, a natural way to represent the dependencies between the pixels of the image is by means of a bidimensional grid-like structure, which can be modeled by a Markov Random Field (MRF) [13]. In this representation, each pixel in the image is represented by a node in the graph and its attributes vector x. In this problem the objective 10
2.3. Gaussian Mixture Models is to find the combination of class labels yfor each feature vector xthat maximizes the probability of the graphical model (Maximum a Posterioriprobability). One way to model this distribution is in terms of the energy associated with a Conditional Random Field (CRF) [12,20]. If F={Ψd} is the set of factors in some factor graph G, where dis an integer index that ranges from 1 to D(being Dthe number of factors), then the conditional distribution for CRF with respect to a set of computed features is: P(y|x) = 1 Z(x)Y ΨD∈F exp (KD X ζ=1 θdζϕdζ (yd,xd))(2.1) where ϕdζ is a feature function, ζ∈K;Kthe number of features, θdζ is the set of weights of each factor d. The constant Z(x)represents the partition function, a normalization factor to ensure the proper definition of the probability distribution. Typically, the parameters θdζ will be learned from data by means of some well known methods, namely: BFGS [2], L-BFGS [4], EM [15], SGD [22] or AROW [11]. 2.3 Gaussian Mixture Models Several methods have been developed to estimate the the probability density function (PDF) of any arbitrary distribution from a set of training samples [6,8,14]. Among the possible distribution functions estimators, Gaussian mixture models (GMM) are widely used in several tasks and have proved to be a powerful tool. A Gaussian mixture model is defined as the result of a weighted sum of MGaussian components: p(x) = M X i=1 πiN(x|µi,Σi)(2.2) where πiparameters are called mixing coefficients and corresponds with the weight of the component i. These coefficients are restricted to satisfy PM i=1 πi= 1. Each Gaussian density N(x|µi,Σi)is called a component of the mixture and has its own mean µiand covariance Σi. Finally, the estimation of each mixture parameter (πi, µi,Σi) is performed by using the Expectation-Maximization (EM) algorithm [8]. 11
Bibliography [14] MacQueen, J. B. (1967). Kmeans Some Methods for classification and Analysis of Multivariate Observations. 5th Berkeley Symposium on Mathematical Statistics and Probability 1967, 1(233):281–297. [15] McCallum, a., Bellare, K., and Pereira, F. (2012). A conditional random field for discriminatively-trained finite-state string edit distance. arXiv preprint arXiv:1207.1406. [16] Nicolas, S., Paquet, T., and Heutte, L. (2006). A Markovian approach for handwritten document segmentation. Proceedings - International Conference on Pattern Recognition, 3:292–295. [17] Phillips, I. T. and Chhabra, A. K. (1999). Empirical Performance Evaluation of Graphics Recognition Systems. IEEE Transactions on Pattern Analysis and Machine Intelligence, 21(9):849–870. [18] Smith, L. I. (2002). A tutorial on principal components analysis. Cornell University. [19] Stamatopoulos, N., Louloudis, G., and Gatos, B. (2015). Goal- Oriented Performance Evaluation Methodology for Page Segmentation Techniques. In 13th International Confrence on Document Analysis and Recognition - ICDAR’15, pages 281–285. [20] Sutton, C. and McCallum, A. (2010). An Introduction to Conditional Random Fields. Machine Learning, 4(4):267–373. [21] Toselli, A. H., Vidal, E., and Casacuberta, F. (2011). Multimodal Interactive Pattern Recognition and Applications. Springer. [22] Vishwanathan, S., Schraudolph, N. N., Schmidt, M. W., and Murphy, K. P. (2006). Accelerated training of conditional random fields with stochastic gradient methods. Proceedings of the 23rd international conference on Machine learning ICML 06, 148:969–976. 18
CHAPTER 3 INTERACTIVE LAYOUT ANALYSIS Chapter Outline 3.1 Interactive Layout Analysis ............. 20 3.2 System Architecture ................. 23 3.3 Pre-processing .................... 24 3.4 Feature Extraction .................. 24 3.5 CRF’s Learning ................... 27 3.6 GMM Learning ................... 28 3.7 User Interaction ................... 29 Bibliography ........................ 30 Lorenzo Quirós Díaz Interactive Layout Analysis
Chapter 3. Interactive Layout Analysis 3.1 Interactive Layout Analysis Document Layout analysis is the process of identifying and categorizing the regions of interest in an image of a document. Commonly, this process is divided into two sub problems [1]: detection and labeling of the different zones in the image (body, illustrations, marginalia) is called geometric layout analysis, and the classification of these zones into their logical role (title, caption, footnote, etc.) is called the logical layout analysis. As an input we have an image X={x1,1, x1,2, .., xn,m}, which is associated with a rectangular grid Gof size n×m. Each image site s is associated to a cell in the grid defined by its coordinates over Gand denoted Gij,1≤i≤n, 1≤j≤m. The site set is denoted S={s1, s2, ..., sD}1≤D≤n×m. Now lets define L={l1, l2, ..., l`}the set of all the possible zones in a Layout, under this definition, Lis a unconstrained set, then any combination of zones is allowed, for instance, paragraph, marginalia, illustrations, lines, words, etc. Notice that, since Lis unconstrained several zones of the same type are allowed as well. In the other hand, each image is associated to some K-zones Layout defined as h∗={h1, h2, ..., hK};h∗⊆L, henceforth, h∗is called the Layout ground-truth of that specific image. Then each site sdbelongs to a single layout zone, i.e., sd=⇒hk;hk∈ h∗, sd∈S. In our case, each layout zone is a rectangle defined by its coordinates over Gas hk= (uk,bk),1≤k≤K. Where ukare the upper-left corner, and bkre the bottom-right ones. Figure 3.1 shows an example of this kind of layout zones. 20
3.1. Interactive Layout Analysis Figure 3.1: Layout zones example. Red=Paragraph, Green=marginalia, Blue=catch-word 3.1.1 Layout Analysis Problem Let define a structured hypotheses space [5]H={h1, h2, ..., hT}aover the site set S, where ht⊆L, 1≤t≤T. We want the hypothesis ˆ hwhich provides the best layout for the site set. Under minimal error criterion, a best hypothesis is shown to be the one which maximizes the posterior probability [2]P(h|S). ˆ h= arg max h∈H P(h|S)(3.1) However, in many cases it is difficult to directly estimate P(h|S)and is better to apply the Bayes rule [5]: ˆ h= arg max h∈H P(S|h) P(h) P(S)= P(h) P(S|h)(3.2) aBased on this definition, His finite but huge; in the worst case, each site sbelongs to a different layout zone; then, |H| is defined by the size of the set of sites and the number of different zones as: |H|=|L|+D−1 D=(|L|+D−1)! D!(|L|−1)! 21
Chapter 3. Interactive Layout Analysis where the term P(S)has been dropped since it does not depend on the maximization variable, h.P(S|h)is the probability of a site set Sgiven the layout hypothesis h, and P(h)is its prior probability. Prior probability P(h)can be modeled by a Gaussian Mixture Model (Mg), which is a Gaussian mixture for each corner of each layout zone, where each corner is assumed independent of the others but constrained to uk>bk∀k∈h(element-wise), by computational reasons. P(h)≈P Mg (h) = K Y k=1 P Mg (uk) P Mg (bk)(3.3) The likelihood, P(S|h), can be approached through a simple naïve Bayes decomposition, under spatial independence assumptionb, as follows: P(S|h) = D Y d=1 P(sd|h)(3.4) where each P(sd|h)can be modeled, for instance, by K-NN, CRF’s, RBMs+linear regression function, NN, etc. Formally, Eq. (3.2) can be re-written as: ˆ h≈arg max h∈H K Y k=1 P Mg (uk) P Mg (bk) Dk Y d=1 P(sd|(uk,bk)) (3.5) where Dkis the sub-set of sites inside the layout zone k. In order to prevent precision issues on our calculations, we apply log in both sides of Eq. (3.5). log ˆ h≈arg max h∈H K X k=1 log P Mg (uk) + log P Mg (bk) + Dk X d=1 log P(sd|(uk,bk))!(3.6) bSpatial independence: each site is independent from the others in the set. 22
3.2. System Architecture 3.1.2 Interactive Framework Interactive framework aims to improve the classical pattern recognition paradigm results by taking into account user feedback. As Layout Analysis problem is defined in Eq. (3.6), system will provide the best hypothesis it can, but if there is any error, user commonly will need to remove the prediction and define layout from scratch. This kind of issues could be minimized by the insertion of the feedback (f) and the feedback history (h0) on the model [5]. taking Eq. (2.6) into Eq. (3.6) an interactive version of the system is defined as: log ˆ h≈arg max h∈H K X k=1 log P Mg (uk|h0, f) + log P Mg (bk|h0, f) + Dk X d=1 log P(sd|(uk,bk), h0, f)!(3.7) As a result, the new system must be designed to compute Eq. (3.6) as a first hypothesis, and then Eq. (3.7) will be computed on each iteration until the presented hypothesis satisfies the user. 3.2 System Architecture The proposed method can be divided into a two stage process: •Stage 1: Traditional Pattern Recognition batch-processing paradigm is performed, using a small training set, thus, we use a small training set to learn about the corpus and train the probabilistic model. •Stage 2: Then, user interaction is used to review the results and correct system mistakes. On each stage, several sub-process must be performed. Figure 3.2 presents a block diagram of the system, and a detailed explanation of each block is presented in further sections in this chapter. 23
Chapter 3. Interactive Layout Analysis Training Page Images Page Layout Annotations Preprocessing Feature Extraction CRFs Model GMM Model TRAINING STAGE 1 Prediction Visualization USER Feedback Decoding Prediction is Correct? NO END STAGE 2 Trained Model Preprocessing Feature Extraction Not seen Page Images Figure 3.2: System Architecture Diagram. 3.3 Pre-processing In order to keep this stage of the project as simple as possible, and under the assumption that pre-processing images will provide an enhancement over system performance, images are only transformed to color intensity space and resolution is reduced by feature extraction constrains. This preprocessing steps are focused on reducing the computational cost instead of improving the system performance. Other well know techniques, such as, noise reduction, binarization and skew correction, would be studied on future project stages. 3.4 Feature Extraction For each site sd∈Swe extract a set of characteristics, this set of characteristics is divided into a two groups: 1. the site color intensity and its neighbors, 2. the site position. First group is extracted from a (w×w) window, centered on the site sdas follows (See Figure 3.3 for a visual 24
3.4. Feature Extraction representation of the process): νd=Y[bd cc−bw 2c:bd cc+bw 2c, d−bd cc−bw 2c:d−bd cc+bw 2c](3.8) where Y[a1:a2, a3:a4]stands for a sub-matrix of Ydefined by the rows from a1to a2and the columns from a3to a4; and Ya matrix containing the value of the color intensity of each site in the set Sof size (r×c); r∗c=D. Then, depending of wthe size of νdcould be very high, for example, if w= 33, the size of νdis 1024. In order to reduce the size of the attributes vector, we take each row of νdas an data input and apply PCA algorithm over it to reduce data dimensionality to a (η×w)new matrix; finally we apply PCA again over this new matrix to reduce attributes matrix to a (η×η)matrix, now this reduced matrix is re-shaped to a (1 ×η2)vector and defined as: βd= vec(Υ(Υ(νd, η)T, η))T(3.9) where vec(·)is the vectorization function [3], and Υ(x, η)is a function that returns the re-scaled or reduced data of input x, by means of PCA algorithm, using the first ηeigenvectors. Finally a set of eleven features are selected based on previous attributes, also ηparameter is anchored to 3, in order to keep βdsmall (only 9 elements): ϕd0=βd ϕd1=βd−1 ϕd2=βd+1 ϕd3=βd−c ϕd4=βd+c ϕd5=βd−1|βd ϕd6=βd|βd+1 ϕd7=βd−c|βd ϕd8=βd|βd+c ϕd9=bd cc ϕd10 =d− bd cc 25
Chapter 3. Interactive Layout Analysis Figure 3.3: Feature extraction process 26
3.5. CRF’s Learning where first eight features are related to site color intensity and final two are the position of the site in the image. Also, "bi-gram" notation (βi|βj) is used on features five to eight in order to represent sequential relationship between the site sdand its neighbors. 3.5 CRF’s Learning As mentioned in Section 2.2, CRF’s is a powerful tool to estimate a posterioriprobability that maximizes the probability of a graphical model. In this work the CRFsuite tool [4] is used to learn a CRF model from features selected in Section 3.4.CRFsuite is an implementation of linear-chain CRFs for labeling sequential data; it is a very well know tool for fast training and tagging. It is very fast and, most important, definition of features is very flexible, which allows the user to define many kind of features. The format of the input data is very well described on the tool’s web site [4]. Based on the format restrictions of the tool, and in order to keep the number of features low (and the model size as well), each feature is internally converted into strings by adding a "-" character between each value; for instance, the feature ϕdζ = [w0, w1, w2, w3, w4, w5, w6, w7, w8] is converted to "ϕdζ=w0-w1-w2-w3-w4-w5-w6-w7-w8". Finally, each feature should look like the following example, where TAB character was replaced by new-line in order to keep it more readable, and feature name changed to keep previous notation: 0 ϕd0=210−127−127−86−131−127−86−123−127 ϕd1=45−127−127−168−131−127−168−123−127 ϕd2=44−127−127−169−131−127−169−123−127 ϕd3=29−127−127−177−122−127−176−132−127 ϕd4=70−127−127−156−130−127−156−124−127 ϕd5=29−127−127−177−122−127−176−132−127|210−127−127−86−131−127−86−123−127 ϕd6=45−127−127−168−131−127−168−123−127|210−127−127−86−131−127−86−123−127 ϕd7=210−127−127−86−131−127−86−123−127|44−127−127−169−131−127−169−123−127 ϕd8=210−127−127−86−131−127−86−123−127|70−127−127−156−130−127−156−124−127 ϕd9=4 ϕd10 =79 After training, marginal probability of each class is extracted using the tag option, giving P(sd|h0)and P(sd|h1), were h0and h1means background and paragraph, respectively. In Figure 3.4 we can see an example of the marginal probabilities obtained from the CRF model. A learning algorithm should be selected by experimentation (see Section 4.3.1 for details). 27
Chapter 4. Experiments and Results defined as a 2D cumulative sum of A: I[x, y] = X x0≤x,y0≤y A(x0, y0)x≤M, y ≤N(4.1) Then, using the integral image any rectangular sum can be computed in four array references [8] (see Figure 4.2), i.e. four accesses to the Imatrix instead of (x˙y)accesses to Ausing the direct approach. Figure 4.2: The sum of the pixels within rectangle D can be computed with four array references. The value of the Integral Image at location 1 is the sum of the pixels in rectangle A. The value at location 2 is A + B, at location 3 is A + C, and at location 4 is A + B + C + D. The sum within D can be computed as 4+1−(2 + 3).[8] Since the CRF model provides the probability of each site in the site set S, we can see it as a matrix and use Integral Image for all related calculations. For example in Eq. (3.7) we need to compute the sum of the probability of each site inside each klayout-zone; this can be computed as: Dk X d=1 log P(sd|(uk,bk)) = Ik[bk] + Ik[uk]−Ik[ukr,bkc]−Ik[bkr,ukc] (4.2) with vectors ukand bkdefined in Section 3.1. 4.2.2 Element-wise to matrix evaluation User interaction requires a system fast enough to keep real time feeling to the user, i.e. less than 1.0 seconds [6]. In this system user interacts as explained on Section 3.7, but direct implementation of Eq. (3.7) using for loops is just not fast enough to keep real time feeling (≈25 seconds per click). In order to reduce the time consumed by the CPU to compute Eq. 34
4.3. Experiments (3.7) a matrix-like version of the equation is implemented. This allows the system to use numpy multidimensional and broadcasting features to reduce delay. Then, Eq. (3.7) is transformed into Eq. (4.3), where sums have been expanded to the specific case of this work (only main paragraph); Ikmeans for the Integral Image of the probabilities of the layout zone k,Pu1and Pb1are the probability matrix from u1and b1GMM models respectively, frand fcare the decoded feedback from the user as the row and column selected respectively. ˆ hb1= arg min I0[n, m] −(I0[fr:n, fc:m] + I0[fr−1, fc−1] −I0[fr−1, fc:m]−I0[fr:n, fc−1]) + (I1[fr:n, fc:m] + I1[fr−1, fc−1] −I1[fr−1, fc:m]−I1[fr:n, fc−1]) +Pu1[fr, fc] + Pb1[fr:n, fc:m] ˆ hu1= arg min I0[n, m] −(I0[fr, fc] + I0[0 : fr−1,0 : fc−1] −I0[0 : fr−1, fc]−I0[fr,0 : fc−1]) + (I1[fr, fc] + I1[0 : fr−1,0 : fc−1] −I1[0 : fr−1, fc]−I1[fr,0 : fc−1]) +Pu1[1 : fr,1 : fc] + Pb1[fr, fc](4.3) where Ik[a1:a2, a3:a4]stands for a sub-matrix of Ikdefined by the rows from a1to a2and the columns from a3to a4; and Ikis of size (n×m). Under this approach, time to compute min value is reduced from ≈25 seconds to ≈0.06 seconds, which is enough for current application. 4.3 Experiments Experiments have been conducted over the selected corpus to obtain the model parameters, such as features to train CRF models, window size of those features, and training algorithm, among others. Parameters search is not exhaustive since main goal of this stage is not to get the best model, but to demonstrate the interactive algorithm features. All the results have been evaluated using the methods presented in Section 2.5. 4.3.1 Conditional Random Fields CRF performance is highly dependent on features selection; because of that, some values of image zoom (Z), window size (W), grid size (G) were 35
Chapter 4. Experiments and Results tested. AROW [5] training algorithm was selected to train the CRF model because is proved to be very fast and results are similar to L-BFGS [2] or others. Results are presented in Appendix 6.2, Table 6.2 for reference. In view of the results, the following parameters are selected to train the final model: Z=0.3, W=33 and G=3. Quantitative results are shown in Table 4.1 and some examples of qualitative results in Figure 4.3, where all pixels inside the blue rectangle are labeled as "paragraph" in the ground-truth. (a) (b) (c) (d) Figure 4.3: CRF’s qualitative results, pixels classified as background in yellow, pixels classified as paragraph in purple. Ground-truth rectangle in blue. Pages a) 0944, b) 0945, c) 0948 and d) 0958. 36
4.3. Experiments Table 4.1: CRF’s site level quantitative results. Page Precision Recall F1 0944 0.908 0.914 0.907 0945 0.953 0.953 0.953 0946 0.958 0.956 0.956 0947 0.951 0.952 0.951 0948 0.949 0.951 0.950 0956 0.894 0.896 0.891 0957 0.946 0.945 0.945 0958 0.931 0.927 0.927 0959 0.952 0.952 0.952 0960 0.955 0.954 0.954 0961 0.950 0.950 0.950 0962 0.909 0.921 0.910 0963 0.919 0.914 0.916 0964 0.909 0.910 0.908 0965 0.942 0.942 0.942 0966 0.947 0.947 0.947 0967 0.945 0.946 0.945 Average 0.936 0.936 0.936 4.3.2 Connected Components Labeling (CCL) Approach Connected components algorithms based on morphological operations are a simple method to detect connected objects or regions in binary images. A simple version of this kind of algorithms [4] is implemented as a point of comparison for the proposed method. Thus, all adjacent sites classified as "paragraph" by the CRF model are grouped; then, we search for the minimum rectangle where all sites of the same group fits; and finally, based on user experience, only the biggest rectangle is selected. See Figure 4.4 for some qualitative examples and Table 4.2 for quantitative results. 37
Chapter 4. Experiments and Results (a) (b) (c) (d) Figure 4.4: CCL results examples, red line. Ground-truth added for reference, blue line. Pages a) 0944, b) 0945, c) 0948 and d) 0958. 38
4.3. Experiments Table 4.2: CCL quantitative results. Page MatchScore GoSR 0944 0.862 0.768 0945 0.958 0.926 0946 0.929 0.877 0947 0.969 0.944 0948 0.965 0.937 0956 0.873 0.782 0957 0.956 0.921 0958 0.923 0.863 0959 0.984 0.971 0960 0.932 0.879 0961 0.967 0.942 0962 0.861 0.765 0963 0.970 0.944 0964 0.878 0.787 0965 0.948 0.908 0966 0.929 0.873 0967 0.950 0.912 Average 0.933 0.882 4.3.3 Prior-Probability Approach Prior-Probability is used to estimate the best "paragraph" coordinates, i.e. we maximize Eq. (3.6) over all (uk,bk)in the image range using a brute force approach and the methods explained in Section 4.2. See Figure 4.5 for some qualitative results examples, and Table 4.3 for quantitative results. 39
Chapter 4. Experiments and Results (a) (b) (c) (d) Figure 4.5: Proposed method results example, blue line for ground-truth, red line for connected components labeling approach, green line for proposed approach. Pages a) 0944, b) 0945, c) 0948 and d) 0958. 40
4.3. Experiments Table 4.3: Proposed method quantitative results. Page MatchScore GoSR 0944 0.924 0.862 0945 0.975 0.956 0946 0.988 0.977 0947 0.968 0.943 0948 0.983 0.969 0956 0.882 0.791 0957 0.978 0.960 0958 0.930 0.875 0959 0.969 0.945 0960 0.988 0.978 0961 0.973 0.952 0962 0.927 0.869 0963 0.937 0.888 0964 0.934 0.878 0965 0.969 0.944 0966 0.974 0.951 0967 0.966 0.940 Average 0.957 0.922 4.3.4 Interactive Approach User is allowed to change system hypothesis by a simple click over the image. This feedback is decoded and a new hypothesis is presented to the user. Number of clicks needed by the user to define the main paragraph and new hypothesis are recorded. Quantitative results are presented on Table 4.4 along with the number of clicks performed by an user. 41
Chapter 4. Experiments and Results Table 4.4: Post-user-feedback quantitative results. Page MatchScore GoSR # Clicks 0944 0.978 0.960 1 0945 0.975 0.956 0 0946 0.988 0.977 0 0947 0.968 0.943 0 0948 0.983 0.969 0 0956 0.974 0.952 2 0957 0.978 0.960 0 0958 0.983 0.969 1 0959 0.969 0.945 0 0960 0.988 0.978 0 0961 0.973 0.952 0 0962 0.975 0.955 1 0963 0.956 0.921 1 0964 0.971 0.947 1 0965 0.969 0.944 0 0966 0.974 0.951 0 0967 0.966 0.940 0 Average 0.975 0.954 — 4.4 Results Discussion CRF model performed an average of 93.6% F1-score. Although the set of features selected were very elemental (only site color intensity and position) and a non-exhaustive parameter search was done, results are very promising for further stages. Misclassification of marginalia and title zones could be because color intensity is a feature more to identify text than to identify the different layout zones. That means that layout zone classification lays mostly on position feature. Also, only two classes have been used for training the CRF model. Although this model provides posterior probability needed for the interactive model, feature selection needs to be improved for further stages of this project. CCL is highly dependent on geometric distribution of posterior probability from the CRF model and, after segmentation, there is no easy and general way to improve raw results. For this reason, this approach is used 42
4.4. Results Discussion only as a point of comparison for the proposed method. Performance computed by GoSR and MatchScore are pretty different (93.2% and 83.2% respectively on average), because the first method is most a measure of how similar are the polygons, but the second method finds how much of the information is on both polygons. Notice that almost all marginalia and title zones have been classified as paragraph. This is due to the high dependence on geometric distribution. Prior-probability plays a main role in next approach; most of the marginalia zones are not longer classified as a paragraph, and rectangle boundary is stretched to text boundary, which relies on a average 4% GoSR improvement over the CCL approach. This is up to a 13% improvement in complex cases (see Table 4.3). Finally, methods studied in the bibliography and the method proposed in this work still have errors that must be fixed manually by some human. The interactive approach based on the proposed method provides the framework to help user to fix those errors. Under that premise, not only the system performance must be computed, but the user effort as well. On this seventeen pages corpus, 65% of the times user made no changes on the first provided hypothesis. Thus, hypothesis is good enough to identify the paragraph. On the other hand, 30% of the times the user performs only one click in order to fix errors in the hypothesis. Finally, only in one case two clicks were needed. Performance average is 97.5% and 95.3% on MathScore and GoSR methods respectively; notice that 100% was not reached in any case because users have a different concept of how much the border of the zone needs to be to the border of the text, or cases where two o more blocks cannot be divided by a single line. See examples on Figure 4.6. 43
CHAPTER 6 APPENDIX Chapter Outline 6.1 Corpus Distribution Table ............. 52 6.2 CRF’s parameter search. .............. 53 Lorenzo Quirós Díaz Interactive Layout Analysis
Chapter 6. Appendix 6.1 Corpus Distribution Table Table 6.1: Corpus Pages Distribution Name ID used to Mss_003357_0944_pag-811[843] 0944 test Mss_003357_0945_pag-812[844] 0945 test Mss_003357_0946_pag-813[845] 0946 test Mss_003357_0947_pag-814[846] 0947 test Mss_003357_0948_pag-815[847] 0948 test Mss_003357_0956_pag-823[855] 0956 test Mss_003357_0957_pag-824[856] 0957 test Mss_003357_0958_pag-825[857] 0958 test Mss_003357_0959_pag-826[858] 0959 test Mss_003357_0960_pag-827[859] 0960 test Mss_003357_0961_pag-828[860] 0961 test Mss_003357_0962_pag-829[861] 0962 test Mss_003357_0963_pag-830[862] 0963 test Mss_003357_0964_pag-831[863] 0964 test Mss_003357_0965_pag-832[864] 0965 test Mss_003357_0966_pag-833[865] 0966 test Mss_003357_0967_pag-834[866] 0967 test Mss_003357_0158_pag-053[057] 0158 train Mss_003357_0159_pag-054[058] 0159 train Mss_003357_0161_pag-056[060] 0161 train Mss_003357_0162_pag-057[061] 0162 train Mss_003357_0163_pag-058[062] 0163 train Mss_003357_0176_pag-071[075] 0176 train Mss_003357_0177_pag-072[076] 0177 train Mss_003357_0178_pag-073[077] 0178 train Mss_003357_0179_pag-074[078] 0179 train Mss_003357_0180_pag-075[079] 0180 train Mss_003357_0181_pag-076[080] 0181 train Mss_003357_0182_pag-077[081] 0182 train Mss_003357_0183_pag-078[082] 0183 train Mss_003357_0184_pag-079[083] 0184 train Mss_003357_0185_pag-080[084] 0185 train Mss_003357_0186_pag-081[085] 0186 train Mss_003357_0187_pag-082[086] 0187 train Mss_003357_0188_pag-083[087] 0188 train Mss_003357_0189_pag-084[088] 0189 train Mss_003357_0190_pag-085[089] 0190 train Mss_003357_0191_pag-086[090] 0191 train Mss_003357_0192_pag-087[091] 0192 train 52
6.2. CRF’s parameter search. 6.2 CRF’s parameter search. Table 6.2: CRF’s parameters search results. Z=zoom, W=window, G=granularity, FT= feature extraction time, TrT= Training time, TeT= Test time, P= Precision, R= Recall, F1= F1-score. # Z W G FT[s] TrT[s] TeT[s] P R F1 1 0.1 9 3 4.916 16.822 1.150 0.899 0.900 0.897 2 0.1 9 9 1.151 0.074 0.117 0.868 0.865 0.859 3 0.1 9 12 0.937 0.035 0.062 0.878 0.874 0.872 4 0.1 17 3 20.448 16.054 0.962 0.894 0.884 0.882 5 0.1 17 9 3.619 0.074 0.092 0.895 0.886 0.884 6 0.1 17 12 2.727 0.019 0.052 0.852 0.833 0.828 7 0.1 33 3 23.603 0.997 0.792 0.843 0.811 0.817 8 0.1 33 9 3.920 0.044 0.084 0.858 0.796 0.804 9 0.1 33 12 2.815 0.015 0.043 0.850 0.714 0.714 10 0.1 65 3 32.006 1.050 0.704 0.684 0.659 0.668 11 0.1 65 9 5.078 0.064 0.067 0.820 0.667 0.687 12 0.1 65 12 3.528 0.029 0.037 0.863 0.712 0.742 13 0.2 9 3 18.714 142.845 4.559 0.866 0.868 0.866 14 0.2 9 9 2.714 0.825 0.523 0.852 0.852 0.847 15 0.2 9 12 2.127 0.290 0.261 0.882 0.885 0.882 16 0.2 17 3 88.976 122.980 4.235 0.866 0.863 0.858 17 0.2 17 9 11.068 5.450 0.422 0.863 0.858 0.851 18 0.2 17 12 6.758 0.219 0.225 0.895 0.896 0.892 19 0.2 33 3 105.599 81.756 4.396 0.905 0.901 0.901 20 0.2 33 9 13.263 1.048 0.410 0.895 0.888 0.887 21 0.2 33 12 8.095 0.246 0.214 0.896 0.889 0.888 22 0.2 65 3 173.887 76.256 3.759 0.853 0.848 0.850 23 0.2 65 9 20.629 0.477 0.393 0.837 0.812 0.819 24 0.2 65 12 12.392 0.287 0.220 0.829 0.803 0.808 25 0.3 9 3 41.491 457.521 12.270 0.829 0.832 0.829 26 0.3 9 9 5.174 19.041 1.207 0.859 0.860 0.859 27 0.3 9 12 3.271 1.414 0.554 0.866 0.868 0.867 28 0.3 17 3 195.334 341.149 10.868 0.881 0.882 0.880 29 0.3 17 9 23.479 17.754 1.117 0.880 0.883 0.880 30 0.3 17 12 13.886 2.578 0.563 0.885 0.888 0.884 31 0.3 33 3 24.153 20.972 9.582 0.936 0.937 0.936 32 0.3 33 9 29.088 15.112 0.973 0.898 0.898 0.896 33 0.3 33 12 16.788 1.933 0.527 0.895 0.892 0.890 34 0.3 65 3 396.537 190.954 9.099 0.901 0.898 0.899 35 0.3 65 9 45.363 2.987 0.927 0.891 0.881 0.883 36 0.3 65 12 26.538 6.580 0.502 0.881 0.870 0.870 53
NOMENCLATURE AROW Adaptive Regularization of Weights BFGS Broyden–Fletcher–Goldfarb–Shanno CCL Connected Components Labeling CRF Conditional Random Field DLA Document Layout Analysis GMM Gaussian Mixture Model IPR Interactive Pattern Recognition L-BFGS Limited-memory BFGS PCA Principal Components Analysis PDF Probabilistic Distribution Function PR Pattern Recognition Lorenzo Quirós Díaz Interactive Layout Analysis
6.2. CRF’s parameter search. 57