Skip to content

Commit 198b9bb

Browse files
committed
feat: add histogram calculation
1 parent 2298cb5 commit 198b9bb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def transform_input(x):
2+
if x == 0:
3+
return 1.0 / 256.0 - 1.0
4+
if x < 0:
5+
x = 0.0
6+
elif x > 1.0:
7+
x = 1.0
8+
else:
9+
x = (1.0 + x * 253.0) / 255.0
10+
return 2.0 * (x * 255.0 + 0.5) / 256.0 - 1.0
11+
12+
13+
def main():
14+
input_values = [
15+
0.0,
16+
0.5,
17+
1.0,
18+
1.5,
19+
-1.5,
20+
]
21+
22+
for x in input_values:
23+
print(f"transform_input({x}) = {transform_input(x)}")
24+
25+
26+
if __name__ == "__main__":
27+
main()

0 commit comments

Comments
 (0)