如何在 Go 中访问 YCbCr 颜色属性

我正在迭代图像的像素,试图获取各个颜色值并将它们平均化。当我这样做时:


bounds := img.Bounds()


for y := bounds.Min.Y; y < bounds.Max.Y; y++ {

  for x := bounds.Min.X; x < bounds.Max.X; x++ {

    fmt.Println(reflect.TypeOf(img.At(x, y)))     

  }

}

我得到color.YCbCr十亿次。如果我没有打印它reflect.TypeOf,我会得到这样的结果:


{154 135 124}   

{153 135 124}   

{152 135 124}   

{152 135 124}   

{151 135 124}   

{149 135 124}   

{147 135 124}   

我需要能够访问个体Y,Cb和Cr的颜色,但是当我尝试img.At(x, y).Cb或者img.At(x, y)['Y']甚至img.At(x, y)[0],我得到告诉我,不同的编译时错误color.Color没有这些方法或不支持索引。


翻过高山走不出你
浏览 189回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go