我开始编写鼠标跟踪脚本作为一个挑战,它会以任何分辨率记录,然后将其全部转换为单一分辨率并输出图像。
我让它在基本层面上工作,所以它相当于只是拉伸所有东西。例如,如果您增加输出的宽度并减少高度,您仍然可以看到单个像素的位置,它们只是非常宽且被压扁。
我想知道是否有人知道我实际上是如何重新采样像素的,尤其是对于奇数分辨率,因此它会产生较少的块状结果?无论如何,显示器通常都是非常标准的分辨率,这不是一个大问题,但让我有点恼火的是我已经尝试过但无法让它工作。
我尝试获取剩余的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 和玩游戏的示例:
编辑:我尝试了 RuDevel 的颜色建议(它没有解决问题,但我认为这是一个很酷的主意)因为当互联网一次掉线几个小时时它有点无聊。图片上的曲目较少,因为我还添加了一些压缩旧值的内容,因此需要启动一个新文件。
结果没有预期的那么好,但作为一个基点,我尝试在彩虹色中循环:
You could maybe trace your movements using a pencil that shifts colors over time (e.g. rainbow- style).
That way you'd be able to trace them much longer than with black lines. However, I'd still expect you'd have to start a fresh trace image every now and then and thus have constantly growing space- requirements over time.
But if you then converted only one segment at a time into a spline, wrote the result to your final output and dropped it immediately you'd need (almost) no extra space for the final conversion.
Another idea would be to compress the extracted splines at significant points on the fly by noting position, direction and speed. That should strongly reduce space- requirements - but defining how to detect such a significant point might be hard.
One method for that might be to define an area (e.g. center area of a 5x5 grid
) to be something like 'the center of mass'. A segment would be noted once when it passes through that center or (for outer lines) at the nearest point towards the center. You'd however need to define some type of 'physics' to reproduce (something comparable to) the original image.
如上所述,对图像的子像素进行上采样也应该起作用,但是您的图像类型-很可能(就其本质而言)-为再现留下很少的不同边缘方向。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句