mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-12 22:54:50 +08:00
Remove NTSC color space.
Reason: it was not clear exactly what this was and what it was for. The color space used for NTSC video is YIQ, not RGB NTSC.
This commit is contained in:
@@ -26,7 +26,6 @@ Supported color spaces
|
||||
Derived from the RGB CIE color space. Chosen such that
|
||||
``x == y == z == 1/3`` at the whitepoint, and all color matching
|
||||
functions are greater than zero everywhere.
|
||||
* NTSC
|
||||
|
||||
:author: Nicolas Pinto (rgb2hsv)
|
||||
:author: Ralf Gommers (hsv2rgb)
|
||||
@@ -44,8 +43,9 @@ References
|
||||
|
||||
from __future__ import division
|
||||
|
||||
__all__ = ['rgb2hsv', 'hsv2rgb', 'rgb2xyz', 'xyz2rgb', 'rgb2rgbcie', 'rgbcie2rgb',
|
||||
'rgb2ntsc', 'ntsc2rgb']
|
||||
__all__ = ['rgb2hsv', 'hsv2rgb', 'rgb2xyz', 'xyz2rgb', 'rgb2rgbcie',
|
||||
'rgbcie2rgb']
|
||||
|
||||
__docformat__ = "restructuredtext en"
|
||||
|
||||
import numpy as np
|
||||
@@ -224,17 +224,6 @@ rgbcie_from_xyz = linalg.inv(xyz_from_rgbcie)
|
||||
rgbcie_from_rgb = np.dot(rgbcie_from_xyz, xyz_from_rgb)
|
||||
rgb_from_rgbcie = np.dot(rgb_from_xyz, xyz_from_rgbcie)
|
||||
|
||||
# from Travis' code. "Matrices from Jain". TODO: find reference.
|
||||
ntsc_from_xyz = np.array([[1.910, -0.533, -0.288],
|
||||
[-0.985, 2.000, -0.028],
|
||||
[0.058, -0.118, 0.896]])
|
||||
|
||||
xyz_from_ntsc = linalg.inv(ntsc_from_xyz)
|
||||
|
||||
# construct matrices to and from rgb:
|
||||
ntsc_from_rgb = np.dot(ntsc_from_xyz, xyz_from_rgb)
|
||||
rgb_from_ntsc = np.dot(rgb_from_xyz, xyz_from_ntsc)
|
||||
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# The conversion functions that make use of the matrices above
|
||||
@@ -409,71 +398,3 @@ def rgbcie2rgb(rgbcie):
|
||||
>>> lena_rgb = rgbcie2rgb(lena_hsv)
|
||||
"""
|
||||
return _convert(rgb_from_rgbcie, rgbcie)
|
||||
|
||||
def rgb2ntsc(rgb):
|
||||
"""RGB to NTSC color space conversion.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
rgb : ndarray
|
||||
The image in RGB format, in a 3-D array of shape (.., .., 3).
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
The image in NTSC format, in a 3-D array of shape (.., .., 3).
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If `rgb` is not a 3-D array of shape (.., .., 3).
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] http://en.wikipedia.org/wiki/NTSC
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> import os
|
||||
>>> from scikits.image import data_dir
|
||||
>>> from scikits.image.io import imread
|
||||
|
||||
>>> lena = imread(os.path.join(data_dir, 'lena.png'))
|
||||
>>> lena_ntsc = rgb2ntsc(lena)
|
||||
"""
|
||||
return _convert(ntsc_from_rgb, rgb)
|
||||
|
||||
def ntsc2rgb(ntsc):
|
||||
"""NTSC to RGB color space conversion.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
ntsc : ndarray
|
||||
The image in NTSC format, in a 3-D array of shape (.., .., 3).
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
The image in RGB format, in a 3-D array of shape (.., .., 3).
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
If `ntsc` is not a 3-D array of shape (.., .., 3).
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] http://en.wikipedia.org/wiki/NTSC
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> import os
|
||||
>>> from scikits.image import data_dir
|
||||
>>> from scikits.image.io import imread
|
||||
|
||||
>>> lena = imread(os.path.join(data_dir, 'lena.png'))
|
||||
>>> lena_ntsc = rgb2ntsc(lena)
|
||||
>>> lena_rgb = ntsc2rgb(lena_hsv)
|
||||
"""
|
||||
return _convert(rgb_from_ntsc, ntsc)
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ from scikits.image.io import imread
|
||||
from scikits.image.color import (
|
||||
rgb2hsv, hsv2rgb,
|
||||
rgb2xyz, xyz2rgb,
|
||||
rgb2rgbcie, rgbcie2rgb,
|
||||
rgb2ntsc, ntsc2rgb
|
||||
rgb2rgbcie, rgbcie2rgb
|
||||
)
|
||||
|
||||
from scikits.image import data_dir
|
||||
@@ -132,28 +131,6 @@ class TestColorconv(TestCase):
|
||||
self.colbars_array)
|
||||
|
||||
|
||||
# RGB to NTSC
|
||||
def test_rgb2ntsc_conversion(self):
|
||||
gt = np.array([[[ 0.96880981, 1.03331573, 0.91265003],
|
||||
[ 0.29994641, 1.01478128, 0.89649967],
|
||||
[ 0.70133987, -0.04145057, 0.86950234],
|
||||
[ 0.03247648, -0.05998501, 0.85335198]],
|
||||
[[ 0.93633333, 1.09330074, 0.05929805],
|
||||
[ 0.26746994, 1.0747663 , 0.04314769],
|
||||
[ 0.66886339, 0.01853444, 0.01615036],
|
||||
[ 0. , 0. , 0. ]]])
|
||||
assert_almost_equal(rgb2ntsc(self.colbars_array), gt)
|
||||
|
||||
|
||||
# NTSC to RGB
|
||||
def test_ntsc2rgb_conversion(self):
|
||||
# only roundtrip test, we checked rgb2ntsc above already
|
||||
assert_almost_equal(ntsc2rgb(rgb2ntsc(self.colbars_array)),
|
||||
self.colbars_array)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user