如何将一组线像素化为矩阵
这看起来是一个非常简单的问题。 有许多线可用作其两个端点。 问题是如何将它们离散成矩阵。然后该矩阵可用于图像处理目的。 下图显示了示例线(黄色)及其相应的像素化演示。 任何语言的一段代码都会有很大的帮助,强烈推荐,当然提前表示赞赏。 请注意,性能和准确性是非常重要的因素。
同样如所演示的,线的每个点必须仅具有一个关联的像素(即矩阵元素)。
It looks a very simple question.
There are many lines available as their two endpoints.
The question is how to discretize them into a matrix. Then the matrix can be used for image processing purposes.
At the following figure example lines (yellow) and their corresponding pixelated demonstrations are shown.
A piece of code in any language would be of great help and strongly recommended and of course is in advance appreciated.
Note that performance and accuracy are very important factors.
Also as demonstrated each point of line must have only one pixel (i.e., element of matrix) associated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是使用 Bresenham 算法。
The easiest way is to use Bresenham's algorithm.