mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
[PR #1510] [IMPROVEMENT] add erosion then dilation after quantization #2235
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1510
State: closed
Merged: Yes
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
This PR is the suggested fix to the infamous OCR noise problem in issue #929
I've checked the discussion there and found that the last step that hasn't been implemented is the erosion-dilation to remove the noise surrounding the text after using the built-in
quantize_mapfunction.I've spent the last two days decrypting the
quantize_mapfunction, partly because of how weird the png format stores the color palette and bitmap seperately and partly because the function output doesn't respect it's input parameters. i.e: when passing themax_color=3to the function, it actually outputs an image with only 2 colors, one of which is transparency.This is a proof of concept of how erosion and dilation do actually fix the problem and improve the output quality by a lot. I've done some experimenting with the kernel size and found that 2x2 is the most suitable for removing that kind of noise.
Right now, there's a small quirk that needs fixing which is that the erosion sometimes removes the second line of the subtitle altogether.
I'll solve that issue and mark the PR as ready for review.