mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
new curve for quad mouse
This commit is contained in:
BIN
resources/D416C_NEC.pdf
Normal file
BIN
resources/D416C_NEC.pdf
Normal file
Binary file not shown.
BIN
resources/png_to_curve/bitmap.png
Normal file
BIN
resources/png_to_curve/bitmap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
@@ -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])
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
27
resources/png_to_curve/old/curve.py
Normal file
27
resources/png_to_curve/old/curve.py
Normal 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)
|
||||
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Reference in New Issue
Block a user