mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-29 18:09:37 +00:00
[PR #1510] [MERGED] [IMPROVEMENT] add erosion then dilation after quantization #2231
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?
📋 Pull Request Information
Original PR: https://github.com/CCExtractor/ccextractor/pull/1510
Author: @ziexess
Created: 3/21/2023
Status: ✅ Merged
Merged: 3/21/2023
Merged by: @cfsmp3
Base:
master← Head:add_erosion_dilation_to_quantize_map📝 Commits (1)
a0bb56badd erosion then dilation after quantization📊 Changes
1 file changed (+53 additions, -3 deletions)
View changed files
📝
src/lib_ccx/ocr.c(+53 -3)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.