Exemplo n.º 1
0
 def test_size_fail(self):
     for sz in (8, 13):
         try:
             fast.corner_detect(self.img0, size=sz)
         except ValueError:
             pass
         else:
             raise Exception("Expected ValueError")
Exemplo n.º 2
0
 def test_basic(self):
     for n in range(9, 13):
         xy = fast.corner_detect(self.img0, size=n)
         height, width = self.img0.shape
         assert len(xy) > 0
         for x, y in xy:
             assert ((x >= 0) and (x < width))
             assert ((y >= 0) and (y < height))
Exemplo n.º 3
0
import os
import numpy as np

from supreme.lib import fast
from supreme.config import data_path
from supreme.io import ImageCollection

import scipy as sp

ic = ImageCollection(os.path.join(data_path, 'toystory/toystory00*.png'),
                     grey=True)

xy0 = fast.corner_detect(ic[0], barrier=30)
xy1 = fast.corner_detect(ic[1], barrier=30)

def mark_feature(img,xy):
    shape = list(img.shape) + [3]
    rgb = np.zeros(shape,np.uint8)
    for band in range(3):
        rgb[:,:,band].flat = img
    for x,y in xy:
        rgb[y,x] = [255,0,0]
    return rgb

img0 = mark_feature(ic[0],xy0)
img1 = mark_feature(ic[1],xy1)

import pylab as P
P.subplot(121)
P.imshow(img0)
P.subplot(122)
Exemplo n.º 4
0
 def test_input_image(self):
     xy0 = fast.corner_detect(self.img0, size=9)
     xy1 = fast.corner_detect(self.img1, size=9)
     assert_array_equal(xy0, xy1)
Exemplo n.º 5
0
 def test_barrier(self):
     xy0 = fast.corner_detect(self.img0, barrier=10)
     xy1 = fast.corner_detect(self.img0, barrier=20)
     assert (len(xy0) > len(xy1))
Exemplo n.º 6
0
    weight_mod, area_mod = dpt_feat(pulses_mod, img1.shape, win_size=window)

    # Ignore features that occur right on boundary
    set_boundary_zero(weight, 5)
    set_boundary_zero(area, 5)
    set_boundary_zero(weight_mod, 5)
    set_boundary_zero(area_mod, 5)

    feat_coord, feat_area = get_brightest_pulses(weight, area, N=dpt_feature_nr)
    feat_mod_coord, feat_mod_area = get_brightest_pulses(weight_mod, area_mod,
                                                         N=dpt_feature_nr)
elif feature_method == 'fast':
    from supreme.lib import fast

    perm = np.random.permutation
    feat_coord = perm(fast.corner_detect(img0,
                                         barrier=fast_barrier))
    print "FAST found %d features." % len(feat_coord)
    feat_coord = [(i,j) for (j,i) in feat_coord]
    feat_mod_coord = perm(fast.corner_detect(img1,
                                             barrier=fast_barrier))

    feat_area = np.ones(len(feat_coord)) * 4
    feat_mod_coord = [(i,j) for (j,i) in feat_mod_coord]
    feat_mod_area = np.ones(len(feat_mod_coord)) * 4
else:
    raise ValueError("Invalid feature extractor specified.")

import matplotlib.pyplot as plt

if show_features:
    plt.subplot(121)
Exemplo n.º 7
0
import os
import numpy as np

from supreme.lib import fast
from supreme.config import data_path
from supreme.io import ImageCollection

import scipy as sp

ic = ImageCollection(os.path.join(data_path, 'toystory/toystory00*.png'),
                     grey=True)

xy0 = fast.corner_detect(ic[0], barrier=30)
xy1 = fast.corner_detect(ic[1], barrier=30)


def mark_feature(img, xy):
    shape = list(img.shape) + [3]
    rgb = np.zeros(shape, np.uint8)
    for band in range(3):
        rgb[:, :, band].flat = img
    for x, y in xy:
        rgb[y, x] = [255, 0, 0]
    return rgb


img0 = mark_feature(ic[0], xy0)
img1 = mark_feature(ic[1], xy1)

import pylab as P
Exemplo n.º 8
0
    set_boundary_zero(weight, 5)
    set_boundary_zero(area, 5)
    set_boundary_zero(weight_mod, 5)
    set_boundary_zero(area_mod, 5)

    feat_coord, feat_area = get_brightest_pulses(weight,
                                                 area,
                                                 N=dpt_feature_nr)
    feat_mod_coord, feat_mod_area = get_brightest_pulses(weight_mod,
                                                         area_mod,
                                                         N=dpt_feature_nr)
elif feature_method == 'fast':
    from supreme.lib import fast

    perm = np.random.permutation
    feat_coord = perm(fast.corner_detect(img0, barrier=fast_barrier))
    print "FAST found %d features." % len(feat_coord)
    feat_coord = [(i, j) for (j, i) in feat_coord]
    feat_mod_coord = perm(fast.corner_detect(img1, barrier=fast_barrier))

    feat_area = np.ones(len(feat_coord)) * 4
    feat_mod_coord = [(i, j) for (j, i) in feat_mod_coord]
    feat_mod_area = np.ones(len(feat_mod_coord)) * 4
else:
    raise ValueError("Invalid feature extractor specified.")

import matplotlib.pyplot as plt

if show_features:
    plt.subplot(121)
    plt.hold(True)