Update image's luminance extraction to current recommendation.
Description
[Tell us about your new feature, improvement, or fix! If relevant, please supplement the PR with images.]
The ITU-R BT.709-1 recommendation from 1993 (Y = 0.2125 R + 0.7154 G + 0.0721 B) is outdated and was replaced by BT.709-6 in 2015.
Adapt the rgb2gray conversion function accordingly to Y = 0.2126 R + 0.7152 G + 0.0722 B.
https://www.itu.int/rec/R-REC-BT.709-1-199311-S/en https://www.itu.int/rec/R-REC-BT.709-6-201506-I/en https://www.itu.int/rec/R-REC-BT.709/en
Checklist
[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]
- [x] Clean style in the spirit of PEP8
- [x] Docstrings for all functions
- [ ] Gallery example in
./doc/examples(new features only) - [ ] Benchmark in
./benchmarks, if your changes aren't covered by an existing benchmark - [ ] Unit tests
[For detailed information on these and other aspects see scikit-image contribution guidelines]
References
[If this is a bug-fix or enhancement, it closes issue # ] [If this is a new feature, it implements the following paper: ]
For reviewers
(Don't remove the checklist below.)
- [ ] Check that the PR title is short, concise, and will make sense 1 year later.
- [ ] Check that new functions are imported in corresponding
__init__.py. - [ ] Check that new features, API changes, and deprecations are mentioned in
doc/release/release_dev.rst. - [ ] Consider backporting the PR with
@meeseeksdev backport to v0.14.x
Hello @mamrehn! Thanks for updating the PR.
- In the file
skimage/color/colorconv.py, following are the PEP8 issues :
Line 781:80: E501 line too long (89 > 79 characters) Line 793:80: E501 line too long (85 > 79 characters)
Comment last updated on January 15, 2019 at 12:19 Hours UTC
These 5 tests just fail due to hard coded ground truth values.
How about a new parameter like mode and rgb2gray(rgb, mode='BT.709-1') as well as rgb2gray(rgb, mode='BT.709-6') (new default) as an option?
Then modify rgb2gray(rgb) (which now uses 'BT.709-6') to rgb2gray(rgb, mode='BT.709-1') in the 5 relevant test functions?
This way, scikit-image users' test code should also be fixable with minimum effort.
Note that the old way of RGB to grayscale conversion is not wrong, just not adapted to human perception on modern (>1993) screens, so rgb2gray(rgb, mode='BT.709-1') does still make sense - at least in a test.
I think it is wise to have different color conversion formats for rgb2gray. Though it is a 1E-3 error, and uint8 images don't even have athat precision, it might trip up some people.
Does this need deprecation? if so, it would probably only be default after it becomes obsolete again....
replaced by BT.709-6 in 2015
Actually those new coeff. are from BT.709-2 from 1995. They do not make a difference for 8 bit BTW.
Hey everyone. It seems like this has been stalled a little bit. I think the option to include a new mode='BT.709-1' parameter and move to mode='BT.709-6' with deprecation warnings would be resonable. However, currently it's not ensured that we will make enough releases before skimage2 to finish a full deprecation cycle (with transition to skimage2 we will be free to make breaking changes, see SKIP4 and most recent discussion #6448).
I understand that this change will lead to small changes for images >8 bit? In that case it's probably easiest to aim for a merge after that transition. So I'm updating the milestone for now. However, @mamrehn, if you want to pick this up again, we can still try to merge it before skimage2 so that the updated standard is at least available as an option.