How to pixelate a set of lines into a matrix

此生再无相见时 提交于 2020-01-13 06:15:10

问题


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.


回答1:


The easiest way is to use Bresenham's algorithm.



来源:https://stackoverflow.com/questions/8397247/how-to-pixelate-a-set-of-lines-into-a-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!