Google Visions pixelFraction 究竟做了什么?它有效吗?

问题描述 投票:0回答:0

对于这张图片

我从 Google Vision API 得到以下结果

 "dominantColors": {
  "colors": [
    {
      "color": {
        "blue": 87,
        "green": 166,
        "red": 118
      },
      "hex": "76A657",
      "percent": 47.960142983984696,
      "percentRounded": 48,
      "pixelFraction": 0.017754942,
      "rgb": "118, 166,\n 87",
      "score": 0.3166112
    },
    {
      "color": {
        "blue": 62,
        "green": 127,
        "red": 110
      },
      "hex": "6E7F3E",
      "percent": 26.1232005541769,
      "percentRounded": 26,
      "pixelFraction": 0.011316337,
      "rgb": "110, 127,\n 62",
      "score": 0.17245357
    },
    {
      "color": {
        "blue": 42,
        "green": 91,
        "red": 107
      },
      "hex": "6B5B2A",
      "percent": 6.3624230471659775,
      "percentRounded": 6,
      "pixelFraction": 0.0036420396,
      "rgb": "107, 91,\n 42",
      "score": 0.042001843
    },
    {
      "color": {
        "blue": 159,
        "green": 20,
        "red": 30
      },
      "hex": "1E149F",
      "percent": 4.660944469237247,
      "percentRounded": 5,
      "pixelFraction": 0.0028616025,
      "rgb": "30, 20,\n 159",
      "score": 0.03076945
    },
    {
      "color": {
        "blue": 141,
        "green": 43,
        "red": 38
      },
      "hex": "262B8D",
      "percent": 2.983079897160585,
      "percentRounded": 3,
      "pixelFraction": 0.0013007284,
      "rgb": "38, 43,\n 141",
      "score": 0.019692946
    },
    {
      "color": {
        "blue": 29,
        "green": 33,
        "red": 101
      },
      "hex": "65211D",
      "percent": 0.8994604352429993,
      "percentRounded": 1,
      "pixelFraction": 0.0003902185,
      "rgb": "101, 33,\n 29",
      "score": 0.0059378315
    },
    {
      "color": {
        "blue": 59,
        "green": 41,
        "red": 78
      },
      "hex": "4E293B",
      "percent": 0.742150899045487,
      "percentRounded": 1,
      "pixelFraction": 0.0006503642,
      "rgb": "78, 41,\n 59",
      "score": 0.004899345
    },
    {
      "color": {
        "blue": 143,
        "green": 117,
        "red": 91
      },
      "hex": "5B758F",
      "percent": 0.44812410197544,
      "percentRounded": 0,
      "pixelFraction": 0.0005202914,
      "rgb": "91, 117,\n 143",
      "score": 0.0029583129
    },
    {
      "color": {
        "blue": 68,
        "green": 201,
        "red": 131
      },
      "hex": "83C944",
      "percent": 0.17566497262548536,
      "percentRounded": 0,
      "pixelFraction": 0.00006503642,
      "rgb": "131, 201,\n 68",
      "score": 0.0011596608
    },
    {
      "color": {
        "blue": 62,
        "green": 141,
        "red": 97
      },
      "hex": "618D3E",
      "percent": 9.644808639385166,
      "percentRounded": 10,
      "pixelFraction": 0.0028616025,
      "rgb": "97, 141,\n 62",
      "score": 0.06367067

我知道分数和百分比在这里意味着什么如何计算图像中的主色?但我不知道 pixelFraction 是如何工作的。在我的理解中,pixelFraction 表示这种颜色占据的图像区域(如果我错了请纠正我)

在图像中,最主要(焦点)颜色的十六进制代码为#76A657,这是一种绿色。如果 pixelFraction 表示此颜色占据的图像区域为什么颜色 #76A657 的 pixelFraction (0.017754942) 比 1E149F 的颜色十六进制代码(它是背景色)的得分更高,即 pixelFraction 为 0.0028616025(0.017754942>0.0028616025),即使在视觉上你清楚地告诉胡椒绿占据了背景颜色的一小部分图像。

python google-vision
© www.soinside.com 2019 - 2024. All rights reserved.