1
# -*- coding: utf-8 -*-
3
% Demo code for matching roughly based on the procedure
6
% "Shape Matching and Object Recognition using Low Distortion Correspondence"
7
% A. C. Berg, T. L. Berg, J. Malik
10
% code Copyright 2005 Alex Berg
12
% questions -> Alex Berg aberg@cs.berkeley.edu
17
from compute_sample_points import compute_sample_points
19
def normalize_descriptors(features,rs,nthetas):
21
% function features = normalize_descriptors(features,rs,nthetas);
23
% normlize the gb descriptors... this can be done based on sample
24
% variation using a population of gb descriptors, but here we
25
% simply normalize each sample by the sqrt of the radius
28
sample_points,sample_points_r,sample_points_rb = compute_sample_points(rs,nthetas)
29
nm = 1./(numpy.sqrt(sample_points_r)+(sample_points_r==0))
31
for fi in range(len(features)):
33
features[fi] = features[fi]/nm.reshape(-1,1).repeat(features[fi].shape[1],axis=1)
35
nm = (numpy.dstack(features)**2).sum(axis=2).sum(axis=1)**.5
36
nm[nm<0.001]=1 #?(0?) -> avoid division by zero
37
for fi in range(len(features)):
38
features[fi] = features[fi]/nm.reshape(-1,1).repeat(features[fi].shape[1],axis=1)