コード例 #1
0
def test_video_buffer_smk():
    # load only 100 images
    video_buffer = io.video_buffer(video_file, nimages=100)
    images_rgb = np.asarray([image for image in video_buffer])
    images_luminance = io.imagearray2luminance(images_rgb, size=None)

    images_luminance_resized = io.imagearray2luminance(images_rgb,
                                                       size=small_size)
コード例 #2
0
def test_imagearray2luminance_reversible():
    # process is reversible
    resized_image = io.resize_image(image_rgb, size=small_size)
    assert resized_image.ndim == 3
    resized_image_luminance = io.imagearray2luminance(resized_image, size=None)
    nimages, vdim, hdim = resized_image_luminance.shape
    assert (vdim, hdim) == small_size
    assert resized_image_luminance.ndim == 3
コード例 #3
0
def test_skimage_compare():
    try:
        import skimage.color
    except ImportError:
        import pytest
        pytest.skip("scikit-image not installed.")

    skimage_luminance = skimage.color.rgb2lab(image_rgb)[..., 0]
    pymoten_luminance = io.imagearray2luminance(image_rgb, size=None)[0]
    np.testing.assert_array_almost_equal(skimage_luminance,
                                         pymoten_luminance,
                                         decimal=13)
コード例 #4
0
def test_video2luminance():
    # test video2luminance generator
    nimages = 256
    video_buffer = io.video_buffer(video_file, nimages=nimages)
    # load and downsample 1000 images
    aspect_ratio = 16 / 9.0
    small_size = (96, int(96 * aspect_ratio))

    luminance_images = np.asarray([io.imagearray2luminance(image, size=small_size).squeeze() \
                                   for image in video_buffer])

    lum = io.video2luminance(video_file, size=small_size, nimages=nimages)
    assert np.allclose(luminance_images, lum)
コード例 #5
0
def test_imagearray2luminance_resizing_image():
    # single images
    image_luminance_resized = io.imagearray2luminance(image_rgb,
                                                      size=small_size)
    vdim, hdim = small_size
    assert (1, vdim, hdim) == image_luminance_resized.shape
コード例 #6
0
def test_imagearray2luminance_image():
    # single images
    image_luminance = io.imagearray2luminance(image_rgb, size=None)