[IMPROVEMENT] Modify -quant 0 option #932
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please prefix your pull request with one of the following: [FEATURE] [FIX] [IMPROVEMENT].
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
This pull request aims at simplifying and making the -quant 0 parameter faster. It does so by reducing the number of distinct color shades available in the palette of the PNG image under processing.
An example would be, say a palette color is (248, 187, 027). The new algorithm reduces this image to (224, 160, 0). This is one quantised value amongst the (888) which can be formed under this algorithm. Since the color palette is reduced and our rect bitmap structures point to palette for their pixel color value; in a way this algorithm decreases the color value to the nearest multiple of 32 for R,G,B; effectively quantising it without much reduction in the actual image visibility.
As can be seen in the below screenshot, this method improves the time taken (92 seconds vs 100 seconds) and also gives a better result than no quantisation.
As is marked in the below screenshot (with no quant algorithm at all), a dialogue is read as "Are you off the deck". This is a mistake which does not happen and is read as "Are you off the clock" with the improved algorithm. The video is provided along with the timestamp to check for authenticity.
At last below is a diff between the two files to see the other error corrections that the method provides, (for example it correctly reads "I" (capital "i") which were read as "|")
For video file, refer issue #929
Minor Addition: Added below line which can be uncommented to output debug.png from ocr_bitmap() function
save_spupng("debug.png", indata, w, h, palette, alpha, 16);