小编Pie*_*tro的帖子

OpenGL中的子像素渲染 - 准确性问题

我需要为摄影测量应用程序生成一系列测试图像.这些应包含具有非常精确已知位置的简单对象(磁盘,矩形等).

考虑到白色背景上的黑色矩形的8位灰度图像,最小的可观察位移(插值后)应为1/256像素,因为每个像素有256种可能的强度等级.

我决定使用OpenGL(使用python + pyglet)来渲染这样的图像,因为稍后我将需要渲染更复杂的(3d场景,立体图像对)

不幸的是,我所达到的最佳精度是在像素/ 10左右,没有使用全强度深度.

是否有可能做得更好,理想情况下 - 实现完整的1/256像素精度?有关如何做到这一点的任何提示,好吗?

示例代码,生成部分磁盘的图像,每帧移动0.01像素

#-*- coding: utf-8 -*-
import pyglet
from pyglet.gl import *
from PIL import Image, ImageGrab

config = pyglet.gl.Config(width = 800, height = 600, sample_buffers=1, samples=16)
window = pyglet.window.Window(config=config, resizable=True) 
window.set_size(800, 600)

printScreenNr = 0

@window.event
def on_draw():
     global printScreenNr
     window.clear()
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

     glLoadIdentity()
     glEnable(GL_LINE_SMOOTH)
     glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

     glTranslated(200, 200,0)

     circleQuad = gluNewQuadric()
     glTranslated(200+(printScreenNr*0.01), 0, 0)
     gluPartialDisk(circleQuad, 0, 50, 500, 500, 0, 180)

@window.event
def on_resize(width, height):
    glViewport(0, 0, …
Run Code Online (Sandbox Code Playgroud)

python opengl pyglet

7
推荐指数
1
解决办法
1349
查看次数

标签 统计

opengl ×1

pyglet ×1

python ×1