def test_integral_intested_points():
    np.random.seed(22)
    f = np.random.rand(16, 16) * 230
    f = f.astype(np.uint8)
    f = surf.integral(f)
    with pytest.raises(TypeError):
        surf.interest_points(f.astype(np.int32), is_integral=True)
Пример #2
0
def test_integral_descriptors():
    np.random.seed(22)
    f = np.random.rand(16, 16) * 230
    f = f.astype(np.uint8)
    f = surf.integral(f)
    points = surf.interest_points(f, is_integral=True)
    surf.descriptors(f.astype(np.int32), points, is_integral=True)
Пример #3
0
def test_integral_descriptors():
    np.random.seed(22)
    f = np.random.rand(16,16)*230
    f = f.astype(np.uint8)
    f = surf.integral(f)
    points = surf.interest_points(f, is_integral=True)
    surf.descriptors(f.astype(np.int32), points, is_integral=True)
Пример #4
0
def test_descriptors_descriptor_only():
    np.random.seed(22)
    f = np.random.rand(256, 256) * 230
    f = f.astype(np.uint8)
    points = surf.interest_points(f, 6, 24, 1)
    full = surf.descriptors(f, points)
    only = surf.descriptors(f, points, descriptor_only=True)
    assert full.size > only.size
Пример #5
0
def test_descriptors_descriptor_only():
    np.random.seed(22)
    f = np.random.rand(256,256)*230
    f = f.astype(np.uint8)
    points = surf.interest_points(f, 6, 24, 1)
    full = surf.descriptors(f, points)
    only = surf.descriptors(f, points, descriptor_only=True)
    assert full.size > only.size
Пример #6
0
def surf_ref(f, ref):
    fi = surf.integral(f.copy())
    points = surf.interest_points(fi, 6, 24, 1, max_points=1024, is_integral=True)
    descs = surf.descriptors(fi, points, is_integral=True, descriptor_only=True)
    if ref is None:
        return descs
    ri = surf.integral(ref.copy())
    descsref = surf.descriptors(ri, points, is_integral=True, descriptor_only=True)
    return np.hstack( (descs, descsref) )
Пример #7
0
def surfref(im):
    from mahotas.features import surf
    import numpy as np

    spoints = surf.interest_points(im.get('protein'), max_points=1024)
    return np.hstack([
            surf.descriptors(im.get('protein'), spoints, descriptor_only=True),
            surf.descriptors(im.get('dna'), spoints, descriptor_only=True),
            surf.descriptors(im.get('er'), spoints, descriptor_only=True),
            surf.descriptors(im.get('tubulin'), spoints, descriptor_only=True),
        ])
Пример #8
0
def test_interest_points_descriptors():
    np.random.seed(22)
    f = np.random.rand(256, 256) * 230
    f = f.astype(np.uint8)
    fi = surf.integral(f)
    spoints = surf.surf(f, 6, 24, 1)
    for arr, is_integral in zip([f, fi], [False, True]):
        points = surf.interest_points(arr, 6, 24, 1, is_integral=is_integral)
        points = list(points)
        points.sort(key=(lambda p: -p[3]))
        points = np.array(points, dtype=np.float64)
        descs = surf.descriptors(arr, points, is_integral)
        assert np.all(descs[:len(spoints)] == spoints)
Пример #9
0
def test_interest_points_descriptors():
    np.random.seed(22)
    f = np.random.rand(256,256)*230
    f = f.astype(np.uint8)
    fi = surf.integral(f)
    spoints = surf.surf(f, 6, 24, 1)
    for arr, is_integral in zip([f,fi], [False, True]):
        points = surf.interest_points(arr, 6, 24, 1, is_integral=is_integral)
        points = list(points)
        points.sort(key=(lambda p: -p[3]))
        points = np.array(points, dtype=np.float64)
        descs = surf.descriptors(arr, points, is_integral)
        assert np.all(descs[:len(spoints)] == spoints)
Пример #10
0
def test_integral_intested_points():
    np.random.seed(22)
    f = np.random.rand(16, 16) * 230
    f = f.astype(np.uint8)
    f = surf.integral(f)
    surf.interest_points(f.astype(np.int32), is_integral=True)
Пример #11
0
def test_integral_intested_points():
    np.random.seed(22)
    f = np.random.rand(16,16)*230
    f = f.astype(np.uint8)
    f = surf.integral(f)
    surf.interest_points(f.astype(np.int32), is_integral=True)
Пример #12
0
def surf(im):
    from mahotas.features import surf
    import numpy as np

    spoints = surf.interest_points(im.get('protein'), max_points=1024)
    return surf.descriptors(im.get('protein'), spoints, descriptor_only=True)
Пример #13
0
import cv2
import numpy as np
from mahotas.features import surf
import milk

img = cv2.imread('img_07473.jpg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

#img = cv2.imread('fly.png',0)
# Create SURF object. You can specify params here or later.
# Here I set Hessian Threshold to 400
#surf = cv2.SURF(400)
#surf = surf.surf(400)

# Find keypoints and descriptors directly
#kp, des = surf.detectAndCompute(img,None)
des = surf.surf(gray)
kp = surf.interest_points(gray, threshold=10)

print(len(kp))
#img2 = cv2.drawKeypoints(img,kp,None,(255,0,0),4)
f2 = surf.show_surf(img, kp[:100], )

cv2.imwrite('surf_keypoints.jpg',img2)