duanhuihui2705 2018-09-11 09:55
浏览 1025
已采纳

golang中的math.Pow是否适合此公式?

Formula:

C1*B+C2B^2+C3*G+C4*G*B+C5*G*B^2+C6*G^2+
C7*G^2*B+C8*R+C9*R*B+C10*R*B^2+C11*R*G+
C12*R*G*B+C13*R*G^2+C14*R^2+C15*R^2*B+
C16*R^2*G+C17*1+C18*R^3+C19*G^3+C20*B^3

Go:

var C1 = -0.0343
var C2 = 0.4062
...snipped

C1*B + C2*math.Pow(B, 2) + C3*G + C4*G*B +
C5*G*math.Pow(B, 2) + C6*G*math.Pow(G, 2) +
C7*math.Pow(G, 2)*B + C8*R + C9*R*B +
C10*R*math.Pow(B, 2) + C11*R*G + C12*R*G*B +
C13*R*math.Pow(G, 2) + C14*math.Pow(R, 2) +
C15*math.Pow(R, 2)*B + C16*math.Pow(R, 2)*G +
C17*1 + C18*math.Pow(R, 3) + C19*math.Pow(G, 3) +
C20*math.Pow(B, 3)

All my code works, but I'm seeing values greater than 1 and I should be expecting values in the range of 0 to 1, so I'm assuming that math.Pow isn't what I should be using. New to Go, any help greatly appreciated.

  • 写回答

1条回答 默认 最新

  • duanpu1963 2018-09-11 10:10
    关注

    Your RGB values are not in the same range as the formula requires. This formula works with R, G and B components in the mathematically normal range of 0 (darkest) to 1 (brightest), not the usual computery range of 0 (darkest) to 255 (brightest).

    Divide RGB by 255.0 before running your formula.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库
  • ¥15 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • ¥15 新硬盘安装的程序总是崩溃,提示遇到错误
  • ¥15 openpcdet自制数据集评估bev精度和3d精度相同
  • ¥15 excel 上下按钮 显示行
  • ¥20 云卓h12pro 数传问题