Search code examples
image-processingtext-recognition

Advise filters to improve text visibility on photo


I need filters to improve text visibility on photo, since it has some noise. Which filters (algorithms) do you know for this purpose?

Now, I use monochrome filter but it doesn't improve image quality. I need to filter can determine medium background of little area and make image monochrome depending on medium background.

For example almost all picture background is white and grey characters but some areas has darker color (grey) and black characters. I need to algorithm can understand that some area of image more darker and make level of black accepting lower.


For example, source image: Photo
And processed photo (median, monochrome filters) Processed photo


Solution

  • Unfortunately I'm not able to provide an accurate and fast answer using an image processing package in code, but I can provide some hints based on some really quick tests done in Photoshop(sorry, visual thinker, slow typist). Worst case scenario, you can run Photoshop filters from Matlab, but the filters are used should be available or not to difficult to implement since I've constraint myself to:

    • Curves
    • Levels
    • High Pass

    In simple terms, I recommend first getting read of the gradient dark to bright gradient: it will be easier to play with contrast/threshold on a more even image. In Photoshop I applied curves (which other people wondered about implementing in code)

    curves curves settings

    Not perfect, but it illustrates the idea of cancelling out a bit of that strong gradient.

    On the resulting image I applied levels:

    levels levels settings

    Afterwards, a high pass:

    high pass

    You can use the high pass result and blend it (overlay) with the previous step which will emphasize the details:

    high pass + overlay

    then apply a stamp filter (a mixture of small Gaussian blur + threshold):

    stamp filter

    or even simpler, on the high pass result, apply curves again or threshold:

    curves curves settings

    The idea is threshold should deal with the segmentation at the last stage and you need to make it's job as easy as possible by cancelling out elements not pertaining to the text itself (like the flash light like gradient). If you need to cleanup small dots later, morphological filter (like erode, then dilate) should help. You can also find some info on detecting gradients as well.