Skip to content

Commit

Permalink
feat: Testing renormalization approaches to KDE
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoDell committed Jul 29, 2023
1 parent 68e520e commit f0a3d6d
Show file tree
Hide file tree
Showing 3 changed files with 845 additions and 5 deletions.
28 changes: 28 additions & 0 deletions docs/experimental/float_to_rgb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import numpy as np
i = 255 + 255*256 + 255*256**2 + 255*256**3
i = 0.000000001
j = 0.000000001
f = int(i*256*256*256*256 - 1)
g = int(j*256*256*256*256 - 1)
print("f:", f)

def converter(n):
f = int(n*256*256*256*256 - 1)
c = np.zeros(4, dtype = float)
c[0] = f % 256
c[1] = float((f % 256**2 - c[0]) // 256)
c[2] = float((f % 256**3 - c[1] - c[0]) // 256**2)
c[3] = float((f % 256**4 - c[2] - c[1] - c[0]) // 256**3)

return c/255

def de_converter(h):
return (255*(h[0] + h[1]*256 + h[2]*256**2 + h[3]*256**3) + 1.0)/(256*256*256*256)

c = converter(i)
d = converter(j)
print(f, g)
print(i)
print(np.array(c))
de = de_converter(c + d)
print(int(de*256*256*256*256 - 1))
10 changes: 5 additions & 5 deletions docs/experimental/viz_kde_class.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from fury.actors.effect_manager import EffectManager
from fury.actors.effect_manager_alt import EffectManager
from fury.window import Scene, ShowManager, record

def normalize(array : np.array, min : float = 0.0, max : float = 1.0, axis : int = 0):
Expand Down Expand Up @@ -45,16 +45,16 @@ def normalize(array : np.array, min : float = 0.0, max : float = 1.0, axis : int
manager.initialize()


n_points = 500
n_points = 1000
points = np.random.rand(n_points, 3)
points = normalize(points, -5, 5)
sigmas = normalize(np.random.rand(n_points, 1), 0.1, 0.3)
points = normalize(points, -5.0, 5.0)
sigmas = normalize(np.random.rand(n_points, 1), 0.1, 0.5)
offset = np.array([0.0, 0.0, 0.0])
points = points + np.tile(offset, points.shape[0]).reshape(points.shape)

effects = EffectManager(manager)

kde_actor = effects.kde(points, sigmas, kernel = "exponential", colormap = "inferno")
kde_actor = effects.kde(points, sigmas, kernel = "gaussian", colormap = "inferno")


manager.scene.add(kde_actor)
Expand Down
Loading

0 comments on commit f0a3d6d

Please sign in to comment.