本文整理汇总了Python中Analyzer.Analyzer.colorz方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.colorz方法的具体用法?Python Analyzer.colorz怎么用?Python Analyzer.colorz使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.colorz方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import colorz [as 别名]
class Builder:
def __init__(self):
self.grabber = Grabber()
self.analyzer = Analyzer()
self.manipulator = Manipulator()
def convertColor(self, hex_color):
value = hex_color.lstrip('#')
lv = len(value)
return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
def getCellColors(self, cells, progress_bar=False):
cell_colors = [x[:] for x in [[0]*len(cells[0])]*len(cells)]
if not progress_bar:
for i in range(0, len(cells)):
for j in range(0, len(cells[0])):
cell_colors[i][j] = self.convertColor(self.analyzer.colorz(cells[i][j], 1)[0])
else:
for i in tqdm(range(0, len(cells)), ncols=50):
for j in range(0, len(cells[0])):
cell_colors[i][j] = self.convertColor(self.analyzer.colorz(cells[i][j], 1)[0])
return cell_colors
def calculateContrast(self, color1, color2):
term1 = (color1[0] - color2[0])**2
term2 = (color1[1] - color2[1])**2
term3 = (color1[2] - color2[2])**2
return math.sqrt(term1 + term2 + term3)
def processImage(self, cell_file):
cell_image = self.manipulator.crop_and_resize(Image.open(cell_file), subimage_width, subimage_height)
subcells = self.manipulator.split_image(cell_image, 2, 2)
cell_image_data = {'pixels':cell_image.tostring(), 'size':cell_image.size, 'mode':cell_image.mode}
return(cell_image_data, self.getCellColors(subcells))