Ejemplo n.º 1
0
def test_lbp_values():
    image = Image([[0.0, 6.0, 0.0], [5.0, 18.0, 13.0], [0.0, 20.0, 0.0]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type="none", padding=False)
    assert_allclose(lbp_img.pixels, 8.0)
    image = Image([[0.0, 6.0, 0.0], [5.0, 25.0, 13.0], [0.0, 20.0, 0.0]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type="riu2", padding=False)
    assert_allclose(lbp_img.pixels, 0.0)
    image = Image([[0.0, 6.0, 0.0], [5.0, 13.0, 13.0], [0.0, 20.0, 0.0]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type="u2", padding=False)
    assert_allclose(lbp_img.pixels, 8.0)
    image = Image([[0.0, 6.0, 0.0], [5.0, 6.0, 13.0], [0.0, 20.0, 0.0]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type="ri", padding=False)
    assert_allclose(lbp_img.pixels, 4.0)
Ejemplo n.º 2
0
def test_lbp_values():
    image = Image([[0., 6., 0.], [5., 18., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='none',
                  padding=False)
    assert_allclose(lbp_img.pixels, 8.)
    image = Image([[0., 6., 0.], [5., 25., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='riu2',
                  padding=False)
    assert_allclose(lbp_img.pixels, 0.)
    image = Image([[0., 6., 0.], [5., 13., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='u2', padding=False)
    assert_allclose(lbp_img.pixels, 8.)
    image = Image([[0., 6., 0.], [5., 6., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='ri', padding=False)
    assert_allclose(lbp_img.pixels, 4.)
Ejemplo n.º 3
0
def test_lbp_values():
    image = Image([[0., 6., 0.], [5., 18., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='none',
                  padding=False)
    assert_allclose(lbp_img.pixels, 8.)
    image = Image([[0., 6., 0.], [5., 25., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='riu2',
                  padding=False)
    assert_allclose(lbp_img.pixels, 0.)
    image = Image([[0., 6., 0.], [5., 13., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='u2', padding=False)
    assert_allclose(lbp_img.pixels, 8.)
    image = Image([[0., 6., 0.], [5., 6., 13.], [0., 20., 0.]])
    lbp_img = lbp(image, radius=1, samples=4, mapping_type='ri', padding=False)
    assert_allclose(lbp_img.pixels, 4.)
def test_windowiterator_lbp_no_padding():
    n_cases = 5
    image_width = np.random.randint(50, 250, [n_cases, 1])
    image_height = np.random.randint(50, 250, [n_cases, 1])
    window_step_horizontal = np.random.randint(1, 10, [n_cases, 1])
    window_step_vertical = np.random.randint(1, 10, [n_cases, 1])
    radius = np.random.randint(3, 5, [n_cases, 1])
    for i in range(n_cases):
        image = Image(np.random.randn(1, image_height[i, 0], image_width[i,
                                                                         0]))
        lbp_img = lbp(image,
                      radius=radius[i, 0],
                      samples=8,
                      window_step_vertical=window_step_vertical[i, 0],
                      window_step_horizontal=window_step_horizontal[i, 0],
                      window_step_unit='pixels',
                      padding=False)
        window_size = 2 * radius[i, 0] + 1
        n_windows_horizontal = len(
            range(window_size - 1, image_width[i, 0],
                  window_step_horizontal[i, 0]))
        n_windows_vertical = len(
            range(window_size - 1, image_height[i, 0],
                  window_step_vertical[i, 0]))
        assert_allclose(lbp_img.shape,
                        (n_windows_vertical, n_windows_horizontal))
Ejemplo n.º 5
0
def test_lbp_channels():
    n_cases = 3
    n_combs = np.random.randint(1, 6, [n_cases, 1])
    channels = np.random.randint(1, 4, [n_cases, 1])
    for i in range(n_cases):
        radius = random.sample(range(1, 10), n_combs[i, 0])
        samples = random.sample(range(4, 12), n_combs[i, 0])
        image = MaskedImage(np.random.randn(channels[i, 0], 40, 40))
        lbp_img = lbp(image, radius=radius, samples=samples,
                      window_step_vertical=3, window_step_horizontal=3,
                      window_step_unit='pixels', padding=True)
        assert_allclose(lbp_img.n_channels, n_combs[i, 0] * channels[i, 0])
Ejemplo n.º 6
0
def test_lbp_channels():
    n_cases = 3
    n_combs = np.random.randint(1, 6, [n_cases, 1])
    channels = np.random.randint(1, 4, [n_cases, 1])
    for i in range(n_cases):
        radius = random.sample(range(1, 10), n_combs[i, 0])
        samples = random.sample(range(4, 12), n_combs[i, 0])
        image = MaskedImage(np.random.randn(channels[i, 0], 40, 40))
        lbp_img = lbp(image, radius=radius, samples=samples,
                      window_step_vertical=3, window_step_horizontal=3,
                      window_step_unit='pixels', padding=True)
        assert_allclose(lbp_img.n_channels, n_combs[i, 0] * channels[i, 0])
Ejemplo n.º 7
0
def test_windowiterator_lbp_padding():
    n_cases = 5
    image_width = np.random.randint(50, 250, [n_cases, 1])
    image_height = np.random.randint(50, 250, [n_cases, 1])
    window_step_horizontal = np.random.randint(1, 10, [n_cases, 1])
    window_step_vertical = np.random.randint(1, 10, [n_cases, 1])
    for i in range(n_cases):
        image = MaskedImage(np.random.randn(1, image_height[i, 0],
                                            image_width[i, 0]))
        lbp_img = lbp(image, window_step_vertical=window_step_vertical[i, 0],
                      window_step_horizontal=window_step_horizontal[i, 0],
                      window_step_unit='pixels', padding=True)
        n_windows_horizontal = len(range(0, image_width[i, 0],
                                         window_step_horizontal[i, 0]))
        n_windows_vertical = len(range(0, image_height[i, 0],
                                       window_step_vertical[i, 0]))
        assert_allclose(lbp_img.shape, (n_windows_vertical,
                                        n_windows_horizontal))
Ejemplo n.º 8
0
def test_windowiterator_lbp_padding():
    n_cases = 5
    image_width = np.random.randint(50, 250, [n_cases, 1])
    image_height = np.random.randint(50, 250, [n_cases, 1])
    window_step_horizontal = np.random.randint(1, 10, [n_cases, 1])
    window_step_vertical = np.random.randint(1, 10, [n_cases, 1])
    for i in range(n_cases):
        image = MaskedImage(np.random.randn(1, image_height[i, 0],
                                            image_width[i, 0]))
        lbp_img = lbp(image, window_step_vertical=window_step_vertical[i, 0],
                      window_step_horizontal=window_step_horizontal[i, 0],
                      window_step_unit='pixels', padding=True)
        n_windows_horizontal = len(range(0, image_width[i, 0],
                                         window_step_horizontal[i, 0]))
        n_windows_vertical = len(range(0, image_height[i, 0],
                                       window_step_vertical[i, 0]))
        assert_allclose(lbp_img.shape, (n_windows_vertical,
                                        n_windows_horizontal))
Ejemplo n.º 9
0
def test_windowiterator_lbp_no_padding():
    n_cases = 5
    image_width = np.random.randint(50, 250, [n_cases, 1])
    image_height = np.random.randint(50, 250, [n_cases, 1])
    window_step_horizontal = np.random.randint(1, 10, [n_cases, 1])
    window_step_vertical = np.random.randint(1, 10, [n_cases, 1])
    radius = np.random.randint(3, 5, [n_cases, 1])
    for i in range(n_cases):
        image = Image(np.random.randn(1, image_height[i, 0],
                                      image_width[i, 0]))
        lbp_img = lbp(image, radius=radius[i, 0], samples=8,
                      window_step_vertical=window_step_vertical[i, 0],
                      window_step_horizontal=window_step_horizontal[i, 0],
                      window_step_unit='pixels', padding=False)
        window_size = 2 * radius[i, 0] + 1
        n_windows_horizontal = len(range(window_size - 1, image_width[i, 0],
                                         window_step_horizontal[i, 0]))
        n_windows_vertical = len(range(window_size - 1, image_height[i, 0],
                                       window_step_vertical[i, 0]))
        assert_allclose(lbp_img.shape, (n_windows_vertical,
                                        n_windows_horizontal))