new curve for quad mouse

This commit is contained in:
dekunukem
2022-08-02 03:01:04 +01:00
parent b6f48828f4
commit 42154c6c23
19 changed files with 947 additions and 880 deletions

BIN
resources/D416C_NEC.pdf Normal file
View File

Binary file not shown.

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -1,27 +1,22 @@
from PIL import Image
im = Image.open('ccc.png', 'r').convert('RGB')
im = Image.open('bitmap.png', 'r').convert('RGB')
width, height = im.size
if width < 128 or height < 128:
print("Wrong size, should be exactly 128x128")
exit()
# x: left 0, right 128
# y: top 0, bottom 128
# x: left 0, right width
# y: top 0, bottom height
pix = im.load()
curve_dict = {}
curve_list = []
for horizontal_location in range(128):
col_dict = {}
for y in range(128):
col_dict[sum(pix[horizontal_location,y])] = y
# print(horizontal_location, 128 - col_dict[min(col_dict.keys())])
curve_dict[horizontal_location] = 128 - col_dict[min(col_dict.keys())]
if curve_dict[horizontal_location] < 0:
curve_dict[horizontal_location] = 0
if curve_dict[horizontal_location] > 127:
curve_dict[horizontal_location] = 127
for x in range(width):
col_list = []
for y in range(height):
col_list.append((y, sum(pix[x,y])))
col_list = sorted(col_list, key=lambda x: x[1])
curve_list.append((x, height - col_list[0][0]))
print(curve_dict)
adjusted_list = [(int(x[0]/4), int((x[1]/255)*12000) + 500) for x in curve_list[::4]]
print(adjusted_list)
print([x[1] for x in adjusted_list])

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,27 @@
from PIL import Image
im = Image.open('ccc.png', 'r').convert('RGB')
width, height = im.size
if width < 128 or height < 128:
print("Wrong size, should be exactly 128x128")
exit()
# x: left 0, right 128
# y: top 0, bottom 128
pix = im.load()
curve_dict = {}
for horizontal_location in range(128):
col_dict = {}
for y in range(128):
col_dict[sum(pix[horizontal_location,y])] = y
# print(horizontal_location, 128 - col_dict[min(col_dict.keys())])
curve_dict[horizontal_location] = 128 - col_dict[min(col_dict.keys())]
if curve_dict[horizontal_location] < 0:
curve_dict[horizontal_location] = 0
if curve_dict[horizontal_location] > 127:
curve_dict[horizontal_location] = 127
print(curve_dict)

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB