我开始编写一个鼠标跟踪脚本作为一个挑战,它将以任何分辨率记录,然后将其全部转换为单个分辨率并输出图像。如何重新采样像素到另一个分辨率?
我有一个基本的工作,所以它是相当于只是伸展一切。例如,如果增加宽度并减小输出的高度,您仍然可以看到各个像素的位置,它们只是很宽而且很挤。
我想知道如果有人知道我如何重新采样像素,特别是对于奇数分辨率,所以它会产生较少的块状结果?由于显示器通常都是非常标准的分辨率,所以它不是一个大问题,但它让我感到很懊恼,因为我尝试过它并且无法实现它。
我试图获得了width/height_multiply
的剩余部分,并添加value * remainder
到外的像素为使他们模糊,如果它是一个奇怪的规模的一种方式,但它产生真的是在没有办法接近我想要什么怪异的结果。
这里是我当前的代码编辑的一点:
required_res = (3840, 2160)
data = {(1920, 1080: {(0, 2): 52, (1, 2): 549, (6, 3): 125}}
for resolution, coordinates in data.iteritems():
width_multiply = required_res[0]/resolution[0]
height_multiply = required_res[1]/resolution[1]
for coordinate, value in coordinates.iteritems():
#Figure out new coordinate
base_coordinate = (int(round(coordinate[0] * width_multiply)),
int(round(coordinate[1] * height_multiply)))
coordinate_list = {base_coordinate: value}
#Increase pixel size if image is bigger
if width_multiply_int and height_multiply_int:
for x in range(-int(width_multiply), int(width_multiply)):
for y in range(-int(height_multiply), int(height_multiply)):
new_coordinate = (base_coordinate[0] + x,
base_coordinate[1] + y)
coordinate_list[new_coordinate] = value
#repeat above bit for "just x" and "just y", it's basically the same
for c in coordinate_list:
try:
new_data[c] = max(new_data[c], value)
except KeyError:
new_data[c] = value
的值只是让画面不走全黑。每个新点基本上都有一个更高的数字,目前它的线性范围从0 = white
到latest = black
。
编辑:一天或三三两两价值的Windows使用的和游戏的Here's an example我试图通过RuDevel颜色的建议(它没有解决的问题,但我认为这是一个很酷的想法),因为当互联网一次下载好几个小时时,它有点无聊。图片上的轨迹较少,因为我还添加了一些压缩旧值的位置,因此需要启动一个新文件。
并没有变成相当以及预期,但作为基点,我在彩虹的颜色试图周期:
您可以从子像素(采样)一直到样条线。使用矢量化版本的动作,您可以在理论上重现任何分辨率。 – RuDevel
这是一个非常好的想法,但它听起来像是难以限制文件大小。在60fps的情况下,每天约有1000万分,除非我错过了一些东西,否则不会有简单的方法去除隐藏点:P – Peter