예제 #1
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)
예제 #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_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
예제 #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
파일: surf.py 프로젝트: luispedro/pyslic
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) )
예제 #6
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),
        ])
예제 #7
0
    def _extract_features(self, X, candidate):

        y, x, radius = int(candidate[0]), int(candidate[1]), candidate[2]
        padded_radius = int(self.padding * radius)

        # compute the coordinate of the patch to select
        x_min = x - padded_radius
        x_min = x_min if x_min < 0 else 0
        y_min = y - padded_radius
        y_min = y_min if y_min < 0 else 0
        x_max = x + padded_radius
        x_max = x_max if x_max > X.shape[0] else X.shape[0] - 1
        y_max = y + padded_radius
        y_max = y_max if y_max > X.shape[1] else X.shape[1] - 1

        patch = X[y_min:y_max, x_min:x_max]

        # compute Zernike moments
        zernike = zernike_moments(patch, radius)

        # compute SURF descriptor
        keypoint = np.array([[y, x, 1, 0.1, 1]])
        surf_descriptor = surf.descriptors(patch, keypoint,
                                           is_integral=False).ravel()
        if not surf_descriptor.size:
            surf_descriptor = np.zeros((70, ))

        return np.hstack((zernike, surf_descriptor))
예제 #8
0
    def _extract_features(self, X, candidate):

        y, x, radius = int(candidate[0]), int(candidate[1]), candidate[2]
        padded_radius = int(self.padding * radius)

        # compute the coordinate of the patch to select
        x_min = max(x - padded_radius, 0)
        y_min = max(y - padded_radius, 0)
        x_max = min(x + padded_radius, X.shape[0] - 1)
        y_max = min(y + padded_radius, X.shape[1] - 1)

        patch = X[y_min:y_max, x_min:x_max]

        # compute Zernike moments
        zernike = zernike_moments(patch, radius)

        # compute SURF descriptor
        scale_surf = radius / self.min_radius
        keypoint = np.array([[y, x, scale_surf, 0.1, 1]])
        surf_descriptor = surf.descriptors(X, keypoint,
                                           is_integral=False).ravel()
        if not surf_descriptor.size:
            surf_descriptor = np.zeros((70, ))

        return np.hstack((zernike, surf_descriptor))
예제 #9
0
    def _extract_features(self, X, candidate):

        row, col, radius = int(candidate[0]), int(candidate[1]), int(
            candidate[2])
        padded_radius = int(self.padding * radius)

        # compute the coordinate of the patch to select
        col_min = max(col - padded_radius, 0)
        row_min = max(row - padded_radius, 0)
        col_max = min(col + padded_radius, X.shape[0] - 1)
        row_max = min(row + padded_radius, X.shape[1] - 1)

        # extract patch
        patch = X[row_min:row_max, col_min:col_max]
        resized_patch = resize(patch, (self.resized, self.resized))

        # compute Zernike moments
        zernike = zernike_moments(patch, radius)

        # compute surf descriptors
        scale_surf = 2 * self.padding * radius / 20
        keypoint = np.array([[row, col, scale_surf, 0.1, 1]])
        surf_descriptor = surf.descriptors(X, keypoint,
                                           is_integral=False).ravel()
        if not surf_descriptor.size:
            surf_descriptor = np.zeros((70,))

        # compute haar-like features
        haar_features = extract_feature_image(resized_patch, self.feature_type,
                                              self.feature_coord)

        return np.hstack((zernike, surf_descriptor, haar_features))
예제 #10
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)
예제 #11
0
파일: test_surf.py 프로젝트: Tfou57/robomow
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)
예제 #12
0
    sigmaval = 30

blobs = feature.blob_doh(img, min_sigma=sigmaval, max_sigma=sigmaval)

passpoints = np.zeros((blobs.shape[0], 5))

for i in range(blobs.shape[0]):
    passpoints[i,
               0], passpoints[i,
                              1], passpoints[i,
                                             2] = blobs[i,
                                                        0], blobs[i,
                                                                  1], blobs[i,
                                                                            2]

desc = surf.descriptors(img,
                        passpoints,
                        is_integral=False,
                        descriptor_only=False)
print passpoints
print desc
#print blobs
#print passpoints

for blob in blobs:
    y, x, r = blob
    scatter(x, y, c='r', s=sigmaval, marker='o')
implot = imshow(img)

show()
예제 #13
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)