'Find a list of matching images for imname.'

def query(self, imname):

    h = self.get_imhistogram(imname)
    candidates = self.candidates_from_histogram(h)
    matchscores = []
    for imid in candidates:
        cand_name = self.con.execute(('select    filename    from    imlist    where    rowid=%d' % imid)).fetchone()
        cand_h = self.get_imhistogram(cand_name)
        cand_dist = sqrt(sum((self.voc.idf * ((h - cand_h) ** 2))))
        matchscores.append((cand_dist, imid))
    matchscores.sort()
    return matchscores
