Research Journal of Recent Sciences _________________________________________________ ISSN 2277-2502 Vol. 4(6), 37-44, June (2015) Res.J.Recent Sci. International Science Congress Association 37 Perspective Rectification in Farsi-Arabic Document Images Arash Rashid Farokhi and Dorna Dehghan2 Department of Electrical Engineering, Boushehr Branch, Islamic Azad University, Boushehr, IRAN Department of Electrical Engineering, Science and Research Branch, Islamic Azad University, Fars, IRANAvailable online at: www.isca.in , www.isca.me Received 21th January 2014, revised 20th March 2014, accepted 18th June 2014Abstract Most of existing perspective rectification algorithms belong to Latin texts, due to special form of Farsi and Arabic writing. Here we introduce a fast rectification algorithm with high accuracy in Farsi/Arabic writing. First an adaptively local threshold extracts binary document image from the gray-scale image. Then by smearing technique, baselines are counted and borders of the document images are calculated. Finally perspectives of document images can be rectified by finding Horizontal and vertical vanishing points and transform them to infinity. Results can verify accuracy of our method. Keywords: Perspective correction, smearing technique, detection of borders, line-like structure. IntroductionDigital cameras are portable, low price and high usage which can capture different kinds of writings like books, newspapers, old documents, etc. although these benefits make digital capturing documents useful, light limitation, environmental condition, camera parameters, document warps and angles between cameras and documents make geometric and photometric distortions which cause problems in OCR and document image analysis1,2. Methods of perspective correction by vanishing point detection have been improved in image document analysis. Detection of horizontal vanishing point along the direction of text baselines is much easier than detection of vertical components of perspective projection which are based on document structures like left and right boundaries visibility. Miao used horizontal and vertical vanishing points to correct distorted document image that placed on the parallel lines corresponding to text lines and formatted column boundaries. But his method does not explain calculation of parallel lines. Yin introduced a fast and Robust vanish point detection algorithm for perspective document images. His proposed technique is as follows: firstly by clustering and voting in Gaussian sphere space, a Fast vanishing point candidate’s detection is estimated. Secondary precise detection of the final vanishing points is done by hybrid approach which means combination of results from clustering and projection analysis. Lu used character stroke boundaries to correct documents when paragraph shapes of images are not available. Unfortunately his algorithm works only on documents with unique font size. Chen used an algorithm based on twice Hough Transform for vanishing point detection. In his method, straight lines should exist in document images. All of these algorithms have been introduced in English texts and researches of correction of perspective distortion in Persian and Arabic document images are very limited. Some of Farsi/Arabic and Latin difference writing are written below: Words are often made of connected Letters which have many different Heights and most of them are written in vertical direction: Letters of a word overlap. It means that letters can’t be separated from each other. Some of the letters have one or more points which are located above or below letter structure. Farsi language has most points in writing which make baseline detecting algorithms difficult to diagnose whether points belong to upper or lower baselines. These differences in Farsi/ Arabic and English texts make Latin-based methods fail in Arabic/Persian documents. Golpardaz introduced an algorithm for Farsi document images that finds corner points of document images and perspective distortion can be rectified by perspective transform formula. But in her method, skew angle of document images should be found and rotated which it takes long time. Sarfaraz presented a technique for recognition Arabic printed text by artificial neural networks. His method structure includes segmentation of the text to individual characters, feature extraction by moment invariant technique and recognition by RBF network. The method he introduced was time consuming. In this paper we proposed a method to rectify: Perspective distortion in Farsi/Arabic document images which has/has not skew angle. Our algorithm is fast and more accurate actually in images with large skew degrees because our method can correct both skew and perspective distortion simultaneously in the least time. Our method consist of two algorithms: the first algorithm is used for counting and thinning baselines and detecting borders of document images. The second algorithm is used to detect vanishing points and rectify perspective distortion. Research Journal of Recent Sciences _____________________________________________________________ ISSN 2277-2502Vol. 4(6), 37-44, June (2015) Res.J.Recent Sci. International Science Congress Association 38 Methodology Here, details of our Novel proposed algorithm is described. A general work flow is shown in figure-1. Image binarization: Binarization means to convert a gray level into two level image and is a pre-processing stage for extracting letters from background. Actually binarization is first and most important stage in document image processing. Here we use an adaptive local thresholding method for binarization called Niblack because of its speed and quality10. Figure-2 shows a binary document image result by Niblack method. Horizontal and vertical smearing: By smearing technique, Characters in each line can connect to each other and number of text lines can be counted. It means that by connected component labeling technique, characters in each line can be separated from other lines with a distinct label. Here we use Horizontal and vertical Smearing technique in combination of two algorithms due to special form of Farsi and Arabic writing. We use vertical smearing after horizontal smearing to connect all of sub_letters and Points to base lines. Smearing label length in vertical direction should be much smaller than Horizontal length because baselines should not connect to each other. Figure-3 shows the result of Horizontal smearing and combination of Horizontal and vertical smearing. Some sub_letters and points covered by this technique are shown too. Text line detection and labeling: In this stage, we label smeared line documents and count them for next stages. We also determine each line beginning; ending, the most top and most bottom points and capture them by rectangles as shown in figure-4a. Finally each line can be captured by the size of smeared line rectangle as shown in figure-4b. Border detection and baseline thinning: This stage is a combination of two algorithms: Initially we calculate midpoints of left and right Height of rectangles as border signs of document image. So we draw borders of document image as figure-4c. Secondary by thinning algorithm, text line blocks are subjected for thinning to obtain skeleton and convert text lines into line- like structures used to calculate horizontal vanishing point. The smeared text lines are suitable for thinning operation that generates one-pixel thickness line-like. figure-5 shows the result of thinning algorithm. Vanishing point detection: Here we calculate Horizontal and vertical vanishing point as Follows: Each pair line-like intersections are calculated as Horizontal vanishing point candidates. Then we vote and cluster candidates to calculate horizontal vanishing point. Figure-1 Work follow algorithm The intersection of border detected lines is calculated as vertical vanishing point. At last, the vanishing point is obtained by combination of previous two steps. Image rectification: By calculation of Horizontal and vertical vanishing point locations , we can write a planar homography to rectify perspective distortion11. For document images, detection of two vanishing points in parallel and perpendicular to text baseline directions are urgent. So we compute the homography for correcting distortion in both directions11. Pilu writes the homography as a rotation of vanishing point X-axis followed by a transform to place detected vanishing point at infinity along the X-axis  \n\n\n \n \n ,  \n\n\n \n\n (1) In our method, we calculate homography for vanishing point perpendicular to text lines too. So vanishing point’s Y Research Journal of Recent Sciences ______ ______________________________ Vol. 4(6), 37-44, June (2015) International Science Congress Association coordinate followed by a transform vanishing point at infinity along Y- axis. Figure rectified image. A. Document image with perspective and skew angle ______________________________ __________ _______________ International Science Congress Association can put detected axis. Figure -6 shows the (A) Figure-2 Document image with perspective and skew angle . B. Binarized image result by Niblack method _______________ ISSN 2277-2502 Res.J.Recent Sci. 39 (A) (B) Binarized image result by Niblack method In the middle In the middle Research Journal of Recent Sciences _____________________________________________________________ ISSN 2277-2502Vol. 4(6), 37-44, June (2015) Res.J.Recent Sci. International Science Congress Association 40 (A) (B) Figure-3 A) Horizontal smearing with some sub_letters shown that could not be connected to base line B) combination of Horizontal and vertical smearing technique. Research Journal of Recent Sciences _____________________________________________________________ ISSN 2277-2502Vol. 4(6), 37-44, June (2015) Res.J.Recent Sci. International Science Congress Association 41 (A) (B) (C) Figure-4 A. Smeared base line captured by rectangles B. baselines captured by rectangles C. border detection of document images Research Journal of Recent Sciences ______ ______________________________ Vol. 4(6), 37-44, June (2015) International Science Congress Association Results and Discussion To check the accuracy of the proposed method, more than 20 perspective and skewed/not skewed camera Arabic images were tested and compared with Golpardaz method. In our experiments, document images are distorted by different skew angles and different shape of perspectives. Golpardaz algorithm, applies gray- scale images with skew and perspective distortion. By a thresholding method, it extracts the binary image. Skew angle of the image is detected and corrected by entropy calculation in each degree rotation. Finally it rectifies document images by 4 points extraction of edge ______________________________ __________ _______________ International Science Congress Association Figure-5 Obtaining line-like structure Figure-6 Rectified document image To check the accuracy of the proposed method, more than 20 perspective and skewed/not skewed camera -based Farsi and Arabic images were tested and compared with Golpardaz In our experiments, document images are distorted by different skew angles and different shape of perspectives. scale images with skew and perspective distortion. By a thresholding method, it extracts the Skew angle of the image is detected and corrected by entropy calculation in each degree rotation. Finally it rectifies document images by 4 points extraction of edge documents. Her method due to calculation of entropy in each degree from -90 to +90 degree s, is a time consuming algorithm and shows condensation in some images. Figure rectification of the proposed method with Golpardaz algorithm. Conclusion As it has been mentioned earlier, a fast rectification algorithm with high accuracy is in troduced which can rectify Arabic and Farsi document images with different skew angle rotations.This algorithm can be used in OCR systems to increase their efficiencies. Rectified images show the efficiency of our algorithm _______________ ISSN 2277-2502 Res.J.Recent Sci. 42 documents. Her method due to calculation of entropy in each s, is a time consuming algorithm condensation in some images. Figure -7 shows some rectification of the proposed method with Golpardaz algorithm. a fast rectification algorithm troduced which can rectify Arabic and Farsi document images with different skew angle rotations.This algorithm can be used in OCR systems to increase their efficiencies. Rectified images show the efficiency of our Research Journal of Recent Sciences ______ ______________________________ Vol. 4(6), 37-44, June (2015) International Science Congress Association A. Distorted document image, B. Rectified with Golpardaz algorithm, C. Rectified image with our proposed algorithm References 1.Kye Kungkik, Jin Ho Kim and IN Ho Lee, Camera Document Recognition Using Hierarchical Classifier, Proceedings of the 2nd WSEAS Conference on remote Sensing Tenerife, Spain, December, 16-18 (2006) 2.Doermann D., Liang J. and Li H., Progress in Camer Based Document Image Analysis, Proceedings of the Seventh International Conference On Document Analysis and recognition, 1, 606–616 (2003)3.Monnier C., Ablavsky V., Holden S. and Sequential correction of perspective warp in camera based doc uments, Proceedings of International conference on document Analysis and Recognition, 394-398 (2005)4.Ligang Miao and Silong Peng, Perspective Rectification ______________________________ __________ _______________ International Science Congress Association Figure-7 Distorted document image, B. Rectified with Golpardaz algorithm, C. Rectified image with our proposed algorithm B. IN Ho Lee, Camera -based Document Recognition Using Hierarchical Classifier, Proceedings of the 2nd WSEAS , International Conference on remote Sensing Tenerife, Canary Islands, Li H., Progress in Camer a- Based Document Image Analysis, Proceedings of the Seventh International Conference On Document Analysis and Snorrason M., Sequential correction of perspective warp in camera - uments, Proceedings of International conference on document Analysis and Recognition, 1, Perspective Rectification of Document Images Based on Morphology, International Conference on Computational Intelligence and Security,2, 1805-1808 (2006) 5.Xu-Cheng Yin, Homg- Wei Hao, Jun Sun Naoi, Robust vanishing point Detection for Mobile cam Based Documents, International conference on document analysis and recognition, 136 6.Lu S.J, Chen B.M and Ko C.C., Perspective rectification of document Images Using Fuzzy Set and morphological operations, Image and Vision computing, (2005)7. Xuehui Chen, Ruiqing Jia, Hui Ren A new vanishing point Detection Algorithm Based on hough transform, Third international joint conference on computation science and optimization, 8.Golpardaz M. and Nezamabadi rectification and skew correction in camera _______________ ISSN 2277-2502 Res.J.Recent Sci. 43 (A) (B) (C) Distorted document image, B. Rectified with Golpardaz algorithm, C. Rectified image with our proposed algorithm of Document Images Based on Morphology, International Conference on Computational Intelligence (2006) Wei Hao, Jun Sun and Satoshi Naoi, Robust vanishing point Detection for Mobile cam - International conference on document 136 -140 (2011) C.C., Perspective rectification of document Images Using Fuzzy Set and morphological Image and Vision computing, 5(23), 541-553 Xuehui Chen, Ruiqing Jia, Hui Ren and Yin bin Zhang, A new vanishing point Detection Algorithm Based on Third international joint conference on computation science and optimization, 2, 440-443 (2010) Nezamabadi -pour H., Perspective rectification and skew correction in camera -based Farsi Research Journal of Recent Sciences _____________________________________________________________ ISSN 2277-2502Vol. 4(6), 37-44, June (2015) Res.J.Recent Sci. International Science Congress Association 44 document images, 7th Iranian machine vision and image processing (MVIP), 1-5 (2011)9.Sarfaraz M., Nawaz S.N.A. and lhuraidly A., Offline Arabic text recognition system, International conference on geometric modeling and graphics, 30-35 (2003)10.Shijian Lu, Ben M. Chen and Chi Chung Ko, A partition approach for the restoration of camera images of planar and curled document, Image Vision Computer, 837-848(2006)11.Pilu M., Extraction of Illusory Linear Clues in perceptively Skewed Documents, computer vision and pattern recognition, 1 (2001)