def lab(filename,extra): I = Image.open(filename) L = ct.rgb_to_cielab_i_X(I,0) L = singularityCL.spec(L,extra) if(extra[3]): a = ct.rgb_to_cielab_i_X(I,1) b = ct.rgb_to_cielab_i_X(I,2) a = singularityCL.spec(a,extra) b = singularityCL.spec(b,extra) return np.vstack((L,a,b)) return np.array(L)
def inner_localMF(I, N, extra): if(N==0): return sg.spec(I,extra) w,h = I.shape # crop? return np.vstack(( inner_localMF(I[0:w/2,0:h/2], N-1, extra), \ inner_localMF(I[0:w/2,h/2:h], N-1, extra), \ inner_localMF(I[w/2:w,0:h/2], N-1, extra), \ inner_localMF(I[w/2:w,h/2:w], N-1, extra) ))
def extractMF(filename): features_fname = filename + '.sift' sift.process_image(filename, features_fname) locs, descriptors = sift.read_features_from_file(features_fname) sh = locs.shape[0] res = np.zeros((sh,SIZE_LOCAL_FEATURE)).astype(np.float32) extra = [20,False,True,False,0,0,0] WIN = 5 for i in range(sh): x = np.int32(round(locs[i][0])) y = np.int32(round(locs[i][1])) I = Image.open(filename) Nx,Ny = I.size a = sg.spec(I.crop((max(x-WIN,0),max(y-WIN,0),min(x+WIN,Nx-1),min(y+WIN,Ny-1))),extra) res[i] = a print res.shape return res