获取位于位图顶部的矢量的像素平均值
我目前正在参与一个硬件项目,将三角形 LED 映射到传统位图图像。我想将三角形向量叠加到图像上并获取该向量范围内的平均像素数据。然而,我不熟悉计算这个所需的数学。有谁有算法或链接可以引导我走向正确的方向吗? (我将其标记为 Python,这是首选,但我对通用算法感到满意!)
我已经创建了我要在这里捕获的内容的基本图像: http://imgur.com/Isjip.gif
I'm currently involved in a hardware project where I am mapping triangular shaped LED to traditional bitmap images. I'd like to overlay a triangle vector onto an image and get the average pixel data within the bounds of that vector. However, I'm unfamiliar with the math needed to calculate this. Does anyone have an algorithm or a link that could send me in the right direction? (I tagged this as Python, which is preferred, but I'd be happy with the general algorithm!)
I've created a basic image of what I'm trying to capture here: http://imgur.com/Isjip.gif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这行得通吗:http://www.blackpawn.com/texts/pointinpoly/default。 html?
Will this work: http://www.blackpawn.com/texts/pointinpoly/default.html ?
您可以对线条部分进行线条光栅化,以确定每个水平扫描线处的每个像素在你的三角形内。将它们的 RGB 值相加并除以得到平均值。
You can do line rasterization on the lineparts to determine for each pixel at each horizontal scanline lie within your triangle. Sum and divide their RGB values to get the average.