3
3
import numpy as np
4
4
import math
5
5
6
- size = 400
6
+ # Setup
7
+ size = 800
8
+ x_range = 3
9
+ y_range = x_range
10
+ threshold = 0.01 # Black line visibility
7
11
8
- res = np .linspace (- 2 , 2 , size * 2 + 1 )
9
- ims = np .linspace (- 2 , 2 , size * 2 + 1 )
12
+ res = np .linspace (- ( x_range / 2 ), x_range / 2 , size * 2 + 1 )
13
+ ims = np .linspace (- ( y_range / 2 ), y_range / 2 , size * 2 + 1 )
10
14
11
15
nums = np .zeros ((len (res ) - 1 , len (ims ) - 1 ), dtype = np .complex_ )
12
16
13
17
for i in range (- size , size ):
14
18
for j in range (- size , size ):
15
- nums [i + size , j + size ] = complex (res [i + size ], ims [j + size ])
19
+ nums [i + size , j + size ] = complex (ims [i + size ], res [j + size ])
16
20
21
+ def g (z ):
22
+ return (z - 1 ) / (z ** 13 + z + 1 )
17
23
18
- # Edit this
19
- def function (complex_num ):
20
- return complex_num ** 2
21
-
24
+ def function (z ):
25
+ return z ** (1 + 10j ) * np .cos (g (z ))
22
26
23
27
24
28
nums = function (nums )
@@ -29,12 +33,14 @@ def function(complex_num):
29
33
30
34
H = np .interp (phase , (- 180 , 180 ), (0 , 360 ))
31
35
S = 0.7 + (1 / 3 ) * (np .log (magnitude ) / np .log (1.6 ) - np .floor (np .log (magnitude ) / np .log (1.6 ))) # alternatively S = 0.5 + 0.5 * (magnitude - np.floor(magnitude))
32
- V = ((np .abs (np .sin (math .pi * nums .real )) ** 0.1 ) * (np .abs (np .sin (math .pi * nums .imag )) ** 0.1 )) * 255 # alternatively V = np.full(phase.shape, 255, dtype="float32")
36
+ V = ((np .abs (np .sin (math .pi * nums .real )) ** threshold ) * (np .abs (np .sin (math .pi * nums .imag )) ** threshold )) * 255 # alternatively V = np.full(phase.shape, 255, dtype="float32")
33
37
34
38
35
39
HSV = np .dstack ((H , S , V )).astype ("float32" , copy = False )
36
40
37
- image = cv2 .cvtColor (HSV , cv2 .COLOR_HSV2BGR ) / 255
41
+ image = np .rot90 (cv2 .cvtColor (HSV , cv2 .COLOR_HSV2BGR ) / 255 , 3 )
42
+
43
+ # cv2.imwrite("complex.png", image * 255)
38
44
39
45
cv2 .imshow ("Complex" , image )
40
46
cv2 .waitKey (0 )
0 commit comments