Skip to content

Commit

Permalink
Add tests to check that the methods result in interpolants
Browse files Browse the repository at this point in the history
  • Loading branch information
maaleske committed Sep 18, 2018
1 parent 97fb470 commit 4dc8bf5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
16 changes: 16 additions & 0 deletions colour_demosaicing/bayer/demosaicing/tests/test_bilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from colour_demosaicing import TESTS_RESOURCES_DIRECTORY
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_bilinear
from colour.demosaicing.bayer import mosaicing_CFA_Bayer

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2015-2018 - Colour Developers'
Expand Down Expand Up @@ -51,6 +52,21 @@ def test_demosaicing_CFA_Bayer_bilinear(self):
read_image(str(RGB.format(pattern))),
decimal=7)

def test_demosaicing_CFA_Bayer_bilinear_interpolant(self):
"""
Tests whether the result of :func:`colour_demosaicing.bayer.\
demosaicing.bilinear.demosaicing_CFA_Bayer_bilinear` agrees
with the original values.
"""

for pattern in ('RGGB', 'BGGR', 'GRGB', 'GBRG'):
CFA_file = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr')

CFA = read_image(str(CFA_file.format(pattern)))
RGB = demosaicing_CFA_Bayer_bilinear(CFA, pattern)
CFA_from_RGB = mosaicing_CFA_Bayer(RGB, pattern)
np.testing.assert_almost_equal(CFA_from_RGB, CFA, decimal=7)


if __name__ == '__main__':
unittest.main()
16 changes: 16 additions & 0 deletions colour_demosaicing/bayer/demosaicing/tests/test_malvar2004.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from colour_demosaicing import TESTS_RESOURCES_DIRECTORY
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_Malvar2004
from colour.demosaicing.bayer import mosaicing_CFA_Bayer

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2015-2018 - Colour Developers'
Expand Down Expand Up @@ -52,6 +53,21 @@ def test_demosaicing_CFA_Bayer_Malvar2004(self):
read_image(str(RGB.format(pattern))),
decimal=7)

def test_demosaicing_CFA_Bayer_Malvar2004_interpolant(self):
"""
Tests whether the result of :func:`colour_demosaicing.bayer.\
demosaicing.bilinear.demosaicing_CFA_Bayer_Malvar2004` agrees
with the original values.
"""

for pattern in ('RGGB', 'BGGR', 'GRGB', 'GBRG'):
CFA_file = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr')

CFA = read_image(str(CFA_file.format(pattern)))
RGB = demosaicing_CFA_Bayer_Malvar2004(CFA, pattern)
CFA_from_RGB = mosaicing_CFA_Bayer(RGB, pattern)
np.testing.assert_almost_equal(CFA_from_RGB, CFA, decimal=7)


if __name__ == '__main__':
unittest.main()
17 changes: 17 additions & 0 deletions colour_demosaicing/bayer/demosaicing/tests/test_menon2007.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from colour_demosaicing import TESTS_RESOURCES_DIRECTORY
from colour_demosaicing.bayer import demosaicing_CFA_Bayer_Menon2007
from colour.demosaicing.bayer import mosaicing_CFA_Bayer

__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2015-2018 - Colour Developers'
Expand Down Expand Up @@ -61,6 +62,22 @@ def test_demosaicing_CFA_Bayer_Menon2007(self):
read_image(str(RGB.format(pattern))),
decimal=7)

def test_demosaicing_CFA_Bayer_Menon2007_interpolant(self):
"""
Tests whether the result of :func:`colour_demosaicing.bayer.\
demosaicing.bilinear.demosaicing_CFA_Bayer_Menon2007` agrees
with the original values.
"""

for pattern in ('RGGB', 'BGGR', 'GRGB', 'GBRG'):
CFA_file = os.path.join(BAYER_DIRECTORY, 'Lighthouse_CFA_{0}.exr')

CFA = read_image(str(CFA_file.format(pattern)))
RGB = demosaicing_CFA_Bayer_Menon2007(CFA, pattern)
CFA_from_RGB = mosaicing_CFA_Bayer(RGB, pattern)
np.testing.assert_almost_equal(CFA_from_RGB, CFA, decimal=7)



if __name__ == '__main__':
unittest.main()

0 comments on commit 4dc8bf5

Please sign in to comment.