Recognize images in Python

I am new to both recognition recognition and Python.

What I'm trying to achieve is to run Tesseract from a Python script to โ€œrecognizeโ€ some specific numbers in .tif.

I thought I could do a workout for Tesseract, but I did not find a similar topic on Google and here in SO.

Basically I have a .tif that contains several images (for example, "arrow", "flower" and other icons), and I want the script to print the name of this icon as output. If he finds an arrow, type โ€œarrowโ€.

Is it possible?

+6
source share
1 answer

This is by no means a complete answer, but if there are several images in tif, and if you know the size in advance, you can standardize image samples before classifying them. You would cut the image into all possible rectangles in tif.

Therefore, when you create a classifier (I do not mention methods here), the final result will be a synthesis of the classification of all the smaller rectangles.

So, if tif is specified, the arrow or flower images are 16 pixels by 16 pixels, say, you can use the Python PIL to create patterns.

from PIL import Image image_samples = [] im = Image.open("input.tif") sample_dimensions = (16,16) for box in get_all_corner_combinations(im, sample_dimensions): image_samples.append(im.crop(box)) classifier = YourClassifier() classifications = [] for sample in image_samples: classifications.append (classifier (sample)) label = fuse_classifications (classifications) 

Again, I did not talk about the training phase of writing YourClassifier . But hopefully this helps in identifying part of the problem.

There are many studies devoted to studying the classification of images, as well as work on cleaning noise in images before their classification.

Consider viewing this beautiful collection of existing Python learning libraries.

http://scipy-lectures.github.com/advanced/scikit-learn/index.html

There are many methods that also apply to images.

+1
source

Source: https://habr.com/ru/post/908327/


All Articles