Frage

I have two modules, and I'm importing 1 elements/objects from each module(program), and i am assigning it to some other variables, but still i am getting this error. my code is:

from CBIR import feature_matrix_db
from experiment import feature_matrix_ip
from scipy.spatial import distance

i = 0
a_list = list()
b_list = list()
a_list.append(feature_matrix_ip)
while i < 50:
   b_list.append(feature_matrix_db[i])
   dist = distance(a_list,b_list)
   print dist
   i = i + 1 

CBIR is a program containing mean of blue, green, and red, along with gray-level co-occurrence matrix features like contrast, energy, homogeneity, and correlation(for the images stored in the DB). and i have stored all these in a single array using 'zip' function with the variable name 'feature_matrix_db'

experiment is a program containing mean of blue, green, and red, along with gray-level co-occurrence matrix features like contrast, energy, homogeneity, and correlation(for the query image). and i have stored all these in a single array using 'zip' function with the variable name 'feature_matrix_ip'

now i am trying to calculate the euclidean distance, and it is giving me the error:

 10 while i < 50:
 11     b_list.append(feature_matrix_db[i])
 ---> 12     dist = distance(a_list,b_list)
 13     print dist
 14     i = i + 1

 TypeError: 'module' object is not callable 

Thanks!

War es hilfreich?

Lösung

Modules are modules not functions.

The distance module contains many functions. You need to choose the one that you want. If, for example, you wanted the usual euclidean distance between, say, (0, 0) and (1, 2), then use:

In [6]: from scipy.spatial import distance
In [7]: distance.sqeuclidean( (0, 0), (1, 2) )
Out[7]: 5

You can read more about the many "distance" functions supported by this module here.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top