Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add remove_transparency pre-processing function #432

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wmanley
Copy link
Contributor

@wmanley wmanley commented Jun 23, 2017

Often stb UIs consist of a transparent overlay over live TV or some other
changable image. The transparency can cause OCR and match failures due to
the background bleeding through. This function replaces these transparent
background with solid colour which can be used as a pre-processing step
before performing a match or ocr.

color is an HTML-style hex colour string of the form #rrggbbaa.

It assumes that an overlay image was alpha-blended according to:

frame = color[rgb] * color[alpha] + underlay * (1 - color[alpha])

where color specifies overlay and alpha.

See https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending

Usage:

remove_transparency('#bf000079', frame=...)

TODO:

  • Tests
  • Release notes.
  • Should it be called "remove translucency" instead of "transparency"?
  • Expose it in stbt.
  • Should we create a new stbt.preprocessing module or just keep jamming stuff into stbt? This doesn't have any dependencies except numpy (not even other stbt functions).

@drothlis
Copy link
Contributor

Should it be called "remove translucency" instead of "transparency"?

Should we create a new stbt.preprocessing module or just keep jamming stuff into stbt? This doesn't have any dependencies except numpy (not even other stbt functions).

wmanley and others added 3 commits July 15, 2017 19:02
Often stb UIs consist of a transparent overlay over live TV or some other
changable image.  The transparency can cause OCR and match failures due to
the background bleeding through.  This function replaces these transparent
background with solid colour which can be used as a pre-processing step
before performing a `match` or `ocr`.

color is an HTML-style hex colour string of the form #rrggbbaa.

It assumes that an overlay image was alpha-blended according to:

    frame = color[rgb] * color[alpha] + underlay * (1 - color[alpha])

where color specifies overlay and alpha.

See https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending

Usage:

    remove_transparency('#bf000079', frame=...)
@drothlis drothlis mentioned this pull request Jul 25, 2017
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants