Yapay sinir ağları ile optik karakter tanıma
Optical character recognition with artificial neural network
Yazar: MURATCAN UZTEMUR
Danışman: PROF. DR. AFİFE LEYLA GÖREN SÜMER
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Kontrol ve Otomasyon Mühendisliği Ana Bilim Dalı / Kontrol ve Otomasyon Mühendisliği Bilim Dalı
Derece: Yüksek Lisans, 2019
Konu: Bilgisayar Mühendisliği Bilimleri-Bilgisayar ve Kontrol = Computer Engineering and Computer Science and Control
Dizin: Karakter tanıma = Character recognition ; Yapay sinir ağları = Artificial neural networks

Özet:
Yapay Sinir Ağları ile Optik Karakter Tanıma genel olarak bir resimde yer alan karakterlerin algılanması ve bu karakterlerin sınıflandırılması olarak ifade edilebilir. Karakterlerin sınıflandırılabilmesi için öncelikle yapay sinir ağının oluşturulması ve ardından yapay sinir ağının farklı geometrik özelliklerde ve şekillerde belirli sayıda görüntü içeren veri seti ile eğitilmesi gereklidir. Veri setinin yeterli sayıda görüntü içermesi ve bu görüntülerin harf numerik karakterlerin özniteliklerini taşıması eğitim sürecinin başarısını doğrudan etkileyen önemli bir noktadır. Veri seti belirlendikten sonra uygun yapay sinir ağı modeli seçilir ve modelin parametreleri öğrenme algoritması ile optimize edilir. Eğitim süreci tamamlandıktan sonra yapay sinir ağı sistemi üzerinde belirli test verileri kullanılarak deneme işlemleri gerçekleştirilebilir ve yapay sinir ağının başarı oranı ve yeterliliği tespit edilebilir.
Kamera ile görüntü işleme sistemleri yardımıyla kullanılan optik karakter tanıma sistemleri günümüzde birçok alanda kullanılmaktadır. Trafik denetleme ve kontrol sistemleri, araç plakası tanımlama, güvenlik ve askeri sistemler, latin tabanlı el yazısı ifadelerin otomatik olarak tanınması, üretim kalite kontrol sistemleri ve buna benzer birçok alanda optik karakter tanıma sistemleri kullanılmakta ve başarılı sonuçlar alınmaktadır. Özellikle son dönemlerde yüksek hıza ve işlem gücüne sahip donanımların geliştirilmesi, kamera cihazlarının çözünürlük, yakınlaşma, odaklanma ve hızları konusunda katedilen gelişmeler ve yazılım geliştirme sürecinde birçok kütüphanenin mevcut olması sayesinde görüntü işleme ve yapay sinir ağı kullanımı yaygınlaşmıştır. Yapay sinir ağlarının kullanımı ile geleneksel programlama yöntemlerine kıyasla daha iyi sonuçlar elde edilebilmek ve günümüz uygulamalarında yazılımın kendisini optimize ederek sürekli gelişmesi sağlanabilmektedir.
Optik karakter tanıma sistemi için yapay sinir ağı modeli birçok farklı yapıda oluşturulabilir. Çok katmanlı yapıların kullanımı ve hatanın geriye yayılım prensibi (Back Propogation) ile tasarlanan model ile eğitim verileri kullanılarak yapay sinir ağının ağırlık parametreleri optimize edilebilir. Ağın eğitim sürecinde konvolüsyon kullanımı ile eğitim verilerinde yer alan görüntülerdeki karakteristik özellikler belirgenleştirilerek özniteliklerin ortaya çıkarılması sağlanarak yapay sinir ağı modelinin başarı oranı yükseltilebilir ve farklı test görüntülerinde iyi sonuç vermesi sağlanabilir. Konvolüsyon kullanılan yapay sinir ağları ile görüntü işleme çalışmalarında eğitim görüntülerinde yer alan geometrik özelliklerin, boyutların ve karakteristik özelliklerin resim üzerinden daha başarılı bir şekilde çıkarılabilir.
Bu tez çalışmasında konvolüsyonel ve çok katmanlı yapay sinir ağı modeli oluşturulmuş olup, rakam ve harf karakterlerinin farklı yönelim ve pozisyonlardaki sabit genişlik ve yükseklikteki resimlerini içeren özel bir veri seti kullanılarak optik karakter tanıma uygulaması geliştirilmiştir. Yapay sinir ağı modelinin oluşturulması, eğitim süreci ve testlerin gerçekleştirilebilmesi için yazılım geliştirilmiş ve kullanıcı arayüzü tasarlanmıştır. Ağın eğitimi tamamlandıktan sonra belli görüntüler üzerinden modelin başarı oranı test edilmiştir. Çalışma kapsamında farklı yapay sinir hücresi ve katman sayılarına, eğitim iterasyon sayılarına, yığın sayılarına ve konvolüsyon kullanılmayan yapılara sahip modeller üzerinde denemeler gerçekleştirilmiş ve projede kullanılan ana model ile diğer yapıların başarı ve hata oranlarının karşılaştırılması yapılmıştır. Yapay sinir ağı modelinin performansı ve karşılaştırma sonuçları incelenmiş ve bu sonuçlar yorumlanmıştır.

Abstract:
Optical character recognition with artificial neural network basically can be defined as detection and classification of characters from an image. In order to classify numerical and letter characters, first artificial neural network must be created and then the artificial neural network must be trained with a data set which includes a certain number of images that have different shapes and geometric features. It is a important point of directly affecting success of training process that data set has a sufficient number of images which are capable of define main attributes of numerical and letter characters. After data set is determined, the suitable artificial neural network model is created and model parameters are optimized with special learning algorithms. Artificial neural network can be tested by using certain test data after training process is completed. Then success rate and adequacy of artificial neural network can be determined. 
Optical character recognition systems with camera and image processing techniques are used in many fields in these days. Optical character recognition technology is used successfully in areas of traffic control systems, licence plate identification systems, military and security systems, automatic recognition of latin-based hand written text, scanning and identification of hand written text documents, production quality control systems, and many other fields. Especially in the recent period, the usage of image processing and artificial neural network has become widespread thanks to the development of high speed and processing hardware, improvements in resolution, focus and speed of the camera devices, and the availability of many libraries in the software development process. It is possible to achieve better results compared to traditional programming methods and optimizing and improving the software itself in recent applications by using artificial neural networks.
The concept of artificial neural networks was introduced in the early of 1940s with the reference of human brain neuron working principle and it has evolved to the present day. Artificial neural networks can be defined as the decision making mechanism by using pre-learned informations which comes from certain samples and data set. Artificial neural networks are widely used in many different areas especially control and autonomous systems because of its ability to learn and decision making abilities. It can achieve high success rates in diffucult problems and it can be used for systems which are hard or impossible for modelling. On the other hand artificial neural networks need high capacity hardware and processing power due to parallel operations of the calculation and distrubuted memory usage. Also unlike the conventional programming techniques, it can be said that artificial neural networks has a fault tolerance since the program outputs do not depend on predetermined exact rules and conditions.
Optical character recognition systems can be designed in many and various structures. Model weight parameters of artificial neural network can be optimized by using multi layer structure and error calculation with Back-Propagation algorithm on the training data set. The success rate of artificial neural network model can be increased and can be achieved to get better results in different test images with the usage of convolution in the training process. Deep learning and high precision results at image recognition and classification stage can be applied with usage of convolution and design of CNN neural network for learning process. Convolutional neural networks can extract the geometric features, dimensions and characteristic features of the training images from image better than non-convolutional model.
Software languages such as Python, R, MATLAB, C++ / C#, Java can be used fort he application of optical character recognition. Python software language has many libraries and application program interfaces in order to implement image processing techniques and artificial neural network model. In this project Python software language has been used for creating, training and testing of artificial neural network model. Image processing software libraries such as OpenCV was used for basic operations and transformations on the images and artificial neural network software library which are Tensorflow and Keras was used to implement artificial neural network and train the model. After the training process complated, same software libraries were used again for testing and evaluating success rate of the artificial neural network model. Graphical user interface has been designed for user interactions and basic operations. Software were developed with modularity to perform easy debug operations and maintanence.
In the first stage of this study, detailed informations and rules about the basic digital image processing techniques and artificial neural network were given before implementation of optical character recognition software with artificial neural network. Mathematical equations has been described at regarding to each software functions which were used to perform basic operations and model background to purpose of defining working principle of software. Digital image processing techniques has been described with pixel definition, image preprocessing techniques such as frequency domain techniques and spacial coordinates techniques and equations were given to perform basic operations. Also image types and conversions were explained. Then structure and mathematical background of artificial neural network models has been described. Model weight values optimization algorithms such as Back-Propagation, Gradient Descent, Delta Rule were explained to determine training process of multi layer artificial neural network. Overfitting and underfitting cased were explained to understand of selection of learning iteration number, learning rate and layer number. Detailed informations about activation functions that can be used for different layers and neurons of artificial neural network model were given and the main reason of purpose of widely used activation functions such as ReLu, softmax etc. were explained.
In this thesis project, optical character recognition model has been created by using feed forward convolutional artificial neural network with multi layer, and special data set which includes fixed size of images of digit and letter characters with different orientations and positions. The main software has been developed and the user interface has been designed in order to create artificial neural network model, training process and tests. The model has been trained by using 62 type of character and 1016 images for each type of character. Batch generation algorithm and software has been developed in order to manage memory efficiently and prevent system errors while artificial neural network training was applying because of huge number of training images that is 62992. The success rate of the model was tested with certain test images after the training process complated. Within the scope of this study, experiments were performed on models of different number of artificial neurons, layers, training iteration numbers, batch sizes, and non-convolutional structures. The main artificial neural network model that defined in the project and the other possible structures were compared regarding to the test results by using success and error values. Then the performance of artificial neural network and comparison results of different model structures has been evaluated and interpreted. 
As a result of this study,  optical character recognition application was developed by using convolutional artificial neural networks and digital image processing techniques. Python programming languages and software libraries were used in order to implement mathematical models of artificial neural network and graphical user interface. Model training and testing were performed with main convolutional neural network model. Other possible artificial neural network structures such as non-convolutional, different number of layers, batch sizes, training iterations etc. has been created and tested for same model and data set for the purpose of comparison of different structures.  It can be said that convolutional neural network model has the best results with %99.99 success rate and 0.00008 error value regarding to experiment results. Convolutional neural network model has better results thanks to extracting main features of training images such as shape, angle, size etc. In conclusion, the generated optical character recognition application was developed and tested on specific images. It can be said that project is working as main design criterias and modular software development techniques was used in this project.