Commit 627940d7fa8e582da882be64e47b95fd0709ba6e

Authored by Anthex
1 parent 2394fdd5

add RGB heatmap to visualisation

Showing 3 changed files with 7 additions and 4 deletions   Show diff stats
@@ -15,4 +15,6 @@ This program aims to compute the approximate location of a mobile terminal for a @@ -15,4 +15,6 @@ This program aims to compute the approximate location of a mobile terminal for a
15 ## Annex : N-Lateration 3D visualisation 15 ## Annex : N-Lateration 3D visualisation
16 visuals.py provides a cool function to graphically represent the N-Lateration distances in a 3D space by creating an animated gif (RMI style) 16 visuals.py provides a cool function to graphically represent the N-Lateration distances in a 3D space by creating an animated gif (RMI style)
17 ### Example 17 ### Example
18 -[Click here to view output gif example](https://dantz.fr/LO53/out.gif?) (too big to be displayed) 18 +[Click here to view output gif example](https://dantz.fr/LO53/out_rgb.gif?) (too big to be displayed)
  19 +
  20 +[Or here for the shades of grey version](https://dantz.fr/LO53/out.gif?)
@@ -297,5 +297,6 @@ def NLateration(data, step=.1, xSize=0.0, ySize=0.0, zSize=0.0): @@ -297,5 +297,6 @@ def NLateration(data, step=.1, xSize=0.0, ySize=0.0, zSize=0.0):
297 if d < minDist: 297 if d < minDist:
298 minDist = d 298 minDist = d
299 minLoc = Location(round(k,2),round(l,2),round(m,2)) 299 minLoc = Location(round(k,2),round(l,2),round(m,2))
300 - imageArray[floor(l*10)].append(d*10+255-min(10+exp(d*2),255)) 300 + d = (max(1-d/10.0, 0))**2
  301 + imageArray[floor(l*10)].append((250-floor(360-d*360), 255, floor(50+d*200)))
301 return (minLoc, minDist, imageArray[0], floor(ySize/step), floor(xSize/step), imageArray) 302 return (minLoc, minDist, imageArray[0], floor(ySize/step), floor(xSize/step), imageArray)
@@ -6,9 +6,10 @@ dataset = [(Location(.5,.5,.5), 3.0), (Location(4.0,.0,.0), 2.0), (Location(4.0, @@ -6,9 +6,10 @@ dataset = [(Location(.5,.5,.5), 3.0), (Location(4.0,.0,.0), 2.0), (Location(4.0,
6 NLat_result = NLateration(dataset) 6 NLat_result = NLateration(dataset)
7 W,H = NLat_result[3], NLat_result[4] 7 W,H = NLat_result[3], NLat_result[4]
8 frames = [] 8 frames = []
  9 +dummy = [0 for _ in range(len(NLat_result[5][0]))]
9 10
10 def createFrame(x,y,nbr): 11 def createFrame(x,y,nbr):
11 - img = Image.new("L",(x,y)) 12 + img = Image.new("HSV",(x,y))
12 img.putdata(NLat_result[5][nbr]) 13 img.putdata(NLat_result[5][nbr])
13 return img 14 return img
14 15
@@ -22,4 +23,3 @@ def exportGif(): @@ -22,4 +23,3 @@ def exportGif():
22 23
23 frames[0].save("out.gif", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) 24 frames[0].save("out.gif", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0)
24 print("gif exported") 25 print("gif exported")
25 -