def extract_lab_histogram(mode, clusters):
nn = neighbors.NearestNeighbors(n_neighbors=1)
nn.fit(clusters)
out_filename = mode + '_color'
try:
os.remove(out_filename)
except:
pass
out = open(out_filename, 'ab')
cnt = 0
with open(mode + '_list') as f:
for line in f:
line = line[:-1]
image = cv2.imread(line)
image = cv2.resize(image, (100, 100))
image = cv2.cvtColor(image, cv2.COLOR_BGR2Lab)
points = image.reshape((-1, 3))
cn = nn.kneighbors(points)
hist = np.histogram(cn[1], bins=50, range=(1, 50))[0]
hist.tofile(out)
cnt = cnt + 1
if cnt % 1000 == 0:
print(cnt)
pixel_sampling.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录