如何处理图像中的浮点坐标值

如何处理图像中的浮点坐标值

本文介绍了如何处理图像中的浮点坐标值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在图像上绘制一些几何图形。问题是坐标是浮动的,所以我无法绘制它们。作为一个解决方法,我正在使用floor();将其截断为最接近的整数。这在某些情况下工作正常,只是它会稍微改变我的图像。

I am plotting some geometry on an image. The problem is the coordinates are coming out as floats, so I am not able to plot them. As a work around I am using floor(); to truncate it to nearest Integer. This works fine in some cases, except that it shifts my image a little bit.

  x=9.7

  x'=floor(x)= 9  //the plot is now at 9 and not at 9.7 as desired, (this is 'shift')

但是如果我的要求是在相等距离绘制多个形状,我面临问题,因为转移(因为floor();)不是每个形状均匀。

这就像数字通信中的量化噪声一样。

But in cases where my requirement is to draw multiple shapes at equal distance I am facing problem as the shift (because of floor();)is not uniform for each shape.
It is just like quantization noise in digital communication.

有什么方法可以解决这个问题吗?

Is there any way I can get around this problem ?

推荐答案

这个问题在计算机图形学中实际上是很常见的问题。 是您目前正在努力解决的问题。您可以找到对该主题的一个很好的介绍。 是一个不错的互动网站,有几种不同的光栅化算法。

This problem is actually quite a common one in computer graphics. Rasterisation is the problem domain you are currently struggling with. You may find Bresenham's line algorithm a good introduction to the topic. Here is a nice interactive site with a few different rasterisation algorithms.

希望有所帮助!

这篇关于如何处理图像中的浮点坐标值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:38