Skip to content

Conversion to grayscale uses wrong formula #2

@rtrussell

Description

@rtrussell

Currently the conversion to grayscale is using the formula:

Uint8 grayedColor=(rr+gg+bb)/3

This is wrong. When converting to grayscale, perceptual weighing must be applied (for example the eye is much less sensitive to blue than to green, so blue appears much darker when converted to grayscale). The most common formula used is that specified in CCIR 601, which is approximately:

0.30 * rr + 0.59 * gg + 0.11 * bb

or if you prefer to do it all in integers:

(30 * rr + 59 * gg + 11 * bb) / 100

There is much more detail available at Stack Overflow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions