HowTo - PPilger/text-detection GitHub Wiki

This howto describes how to parameterize a new image.

Set up a new TextDetector

  1. Create a new class that implements the interface TextDetector.
  2. Implement the method getName to return the name of the map. The name is used for the output files.
  3. Implement the method getImage to return the images you are working with. You may have more than one image if you detect different types of text seperately.
  4. Implement the method getFeatures to return the feature sets you are working with. As with the images you might have more of them (for each image).
  5. Implement all other methods with an empty body.
  6. Create object variables for your image(s) and feature set(s) and initialize them in the constructor.
  7. Register your TextDetector in the main method in the class TextDetection by initializing the detector variable with your new class.

Three TextDetector classes are already implemented as examples: BritishIsles, Mooskirchen and PortolanAtlas

Implementing the method imageProcessing

You can get general information about image processing [here](Image Processing).

  1. Create a new ImageDisplay so you are able to display your interim results. You may create several displays to compare several different images at once.
  2. The first step in processing is to create a binary image. For this you should use a BackgroundProcessor.
  3. All further steps are up to you.

Processing an image

To process an image you should use the method <image>.process(...). The parameters and how to set them is described on the page of the processor.

Displaying the correct image

There are several types of images stored in an Image object. Use the display to display one of them.

  • Use 'getImg' to get the binary image. It is input and output for all image processors.
  • Use 'getColor' to get the original color image.
  • Use 'getGray' to get the grayscale image of the original.

How to improve the image

Too small or too large objects

Should be removed in the next step feature detection. If this is not possible or delivers bad results use:

  • PerimeterProcessor, ThicknessProcessor or SkelettonProcessor
  • FirstDerivativeProcessor or SecondDerivativeProcessor (too large objects only)

Objects with a different color than text

Use ChromaticityProcessor.

Remove lines through the image

Use DensityProcessor or LineSegmentsProcessor in combination with EraseProcessor. For the latter one you will have to copy the image and maybe do a seperate processing for it.

Letters are split into fragments

Use CloseProcessor or DilateProcessor.

Implementing the method featureDetection

You can get general information about feature detection [here](Feature Detection).

  1. Create a new 'ContourFeatureDetector' and invoke the method findFeatures.
  2. To test your parameters run the program and look at the output file (<output of getName()>.jpg).
  3. Add rules to the detector (bevore invoking the method findFeatures) to remove invalid objects and test them like in step 2.

Implementing the method featureLinking

You can get general information about feature linking [here](Feature Linking).

  1. Create a new 'BestDirectionFeatureLinker' and invoke the method link. Store the return value in your feature set.
  2. Add rules to the linker (bevore invoking the method link).
  3. To test your parameters run the program and look at the output file (<output of getName()>.jpg).

Implementing the method featureFiltering

Remove all features from your feature set(s) that are no text. This can be done using [feature rules] (FeatureRule).

Implementing the method featureMerging

If you have more than one feature set, you can merge them here, using the merge method of FeatureSet.

⚠️ **GitHub.com Fallback** ⚠️