问题
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:
And processed photo (median, monochrome filters)
回答1:
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)
Not perfect, but it illustrates the idea of cancelling out a bit of that strong gradient.
On the resulting image I applied levels:
Afterwards, a high pass:
You can use the high pass result and blend it (overlay) with the previous step which will emphasize the details:
then apply a stamp filter (a mixture of small Gaussian blur + threshold):
or even simpler, on the high pass result, apply curves again or threshold:
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.
回答2:
You could provide an example image.
If you want to make an image black and white you can use a threshold operation as long as your text is darker than the darkest background value.
Compare every pixel vs the global threshold. If higher set it to new value a, if lower set it to new value b. For equals you have to choose one option.
If not you can use a so called local threshold. Here you calculate the threshold for every pixel from its sourrounding. There are many algorithms for calulating that local threshold value.
To name a few local thresholding algorithms: Bernsen Sauvola Mean Median MidGrey Niblack
They all calculate threshold values based on some limited area around your pixel.
来源:https://stackoverflow.com/questions/35276538/advise-filters-to-improve-text-visibility-on-photo