name.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:color-extractor 作者: algolia 项目源码 文件源码
def _hard_monochrome(self, sample):
        """
        Return the monochrome colors corresponding to `sample`, if any.
        A boolean is also returned, specifying whether or not the saturation is
        sufficient for non monochrome colors.
        """
        gray_proj = np.inner(sample, Name._GRAY_UNIT) * Name._GRAY_UNIT
        gray_dist = norm(sample - gray_proj)

        if gray_dist > 15:
            return []

        colors = []
        luminance = np.sum(sample * Name._GRAY_COEFF)
        if luminance > 45 and luminance < 170:
            colors.append(self._settings['gray_name'])
        if luminance <= 50:
            colors.append(self._settings['black_name'])
        if luminance >= 170:
            colors.append(self._settings['white_name'])

        return colors

    # Normalized identity (BGR gray) vector.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号