【问题标题】:How to get the percentage of color from image_properties in google vision api?如何从 google vision api 中的 image_properties 获取颜色百分比?
【发布时间】:2019-11-09 03:34:23
【问题描述】:

我正在尝试使用 Google Vision API 进行颜色检测。为此,我正在使用 python 库。当我获取 image_properties 时,我得到如下结果

colors {
  color {
    red: 52.0
    green: 94.0
    blue: 96.0
  }
  score: 0.11754503101110458
  pixel_fraction: 0.04190981388092041
}

但是如何计算在这种情况下得出的百分比为“18%”

Actual Output of the Google Vision Api

【问题讨论】:

    标签: google-cloud-storage google-cloud-vision google-vision


    【解决方案1】:

    我假设你已经使用Vision demo 得到了这个result。这个百分比 (18%) 的计算方法是将每个颜色记录的 score 除以所有分数的总和:

    % "百分比" = 分数 / (score1 + score2 + score3 + ... + scoreN)

    【讨论】:

    • 谢谢,这个公式似乎得到了正确的数字,只是一个后续问题,pixel_fraction 的重要性是什么?
    • pixel_Fraction 显示颜色在图像中所占的像素分数。对于某些人来说,它对于深入的图像分析很有用。
    • 与百分比有何不同?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    • 2015-12-19
    • 2015-07-20
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多