Skip to content

Conversation

@thealphadollar
Copy link
Contributor

@thealphadollar thealphadollar commented Feb 21, 2018

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):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

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.

With 8-bit color reduction

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.

without color reduction

video screenshot

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 "|")

difference between the two extracted subtitles

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);

@cfsmp3
Copy link
Contributor

cfsmp3 commented Feb 21, 2018

  • case 0 means "pass the image unchanged to tessearact", so it cannot do any kind of processing.
  • You can add that new code to case 2 (but test that it actually helps in some cases, otherwise no point in adding it)
  • Remember that the help text needs to be updated as well.

@thealphadollar
Copy link
Contributor Author

The proposed algorithm improves speed and gives slightly better results as is shown in the PR content.

Updated help and made it case 2 :)

@cfsmp3 cfsmp3 merged commit 9dc1e0a into CCExtractor:master Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants