如何将一组线像素化为矩阵

发布于 2024-12-19 20:31:14 字数 267 浏览 2 评论 0原文

这看起来是一个非常简单的问题。 有许多线可用作其两个端点。 问题是如何将它们离散成矩阵。然后该矩阵可用于图像处理目的。 下图显示了示例线(黄色)及其相应的像素化演示。 任何语言的一段代码都会有很大的帮助,强烈推荐,当然提前表示赞赏。 请注意,性能和准确性是非常重要的因素。
同样如所演示的,线的每个点必须仅具有一个关联的像素(即矩阵元素)。

在此处输入图像描述

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.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溇涏 2024-12-26 20:31:15

最简单的方法是使用 Bresenham 算法

The easiest way is to use Bresenham's algorithm.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文