src/Visualise.jl

changeset 14
8ff303666d8b
parent 13
bda471ea9d67
child 15
6ac8641e7cfb
equal deleted inserted replaced
13:bda471ea9d67 14:8ff303666d8b
6 6
7 using Printf 7 using Printf
8 using FileIO 8 using FileIO
9 using Setfield 9 using Setfield
10 using ColorTypes: Gray 10 using ColorTypes: Gray
11 using Plots 11 #using Plots
12 using Measures 12 #using Measures
13 import GR
13 14
14 using AlgTools.Util 15 using AlgTools.Util
15 using AlgTools.StructTools 16 using AlgTools.StructTools
16 using AlgTools.LinkedLists 17 using AlgTools.LinkedLists
17 18
76 do_visualise(imgs) 77 do_visualise(imgs)
77 end 78 end
78 return 79 return
79 end 80 end
80 81
82 # function do_visualise(imgs)
83 # plt = im -> plot(grayimg(im), showaxis=false, grid=false, aspect_ratio=:equal, margin=2mm)
84 # display(plot([plt(imgs[i]) for i =1:length(imgs)]..., reuse=true, margin=0mm))
85 # end
86
87 grayGR = x -> begin
88 y = round(UInt32, 0xff*clip(x))
89 return 0x010101*y + 0xff000000
90 end
91
81 function do_visualise(imgs) 92 function do_visualise(imgs)
82 plt = im -> plot(grayimg(im), showaxis=false, grid=false, aspect_ratio=:equal, margin=2mm) 93 n = length(imgs)
83 display(plot([plt(imgs[i]) for i =1:length(imgs)]..., reuse=true, margin=0mm)) 94 # Get device dimensions in metres and pixels
95 scrw, scrh, pw, ph = GR.inqdspsize()
96 # Scaling to maximums ize window
97 sc=0.7
98 # Set up window and transformations
99 GR.clearws()
100 GR.setscale(0);
101 GR.selntran(1)
102 # - First OS window size
103 if scrw/n>scrh
104 GR.setwsviewport(0, sc*scrh*n, 0, sc*scrh)
105 else
106 GR.setwsviewport(0, sc*scrw, 0, sc*scrw/n)
107 end
108 # - Part of normalised window shown
109 GR.setwswindow(0, 1, 0, 1/n);
110 GR.setviewport(0, 1, 0, 1/n);
111 # Workd coordinates
112 GR.setwindow(0, n, 0, 1)
113 # Plot images
114 for i=1:n
115 im = imgs[i]'
116 sz = size(im)
117 GR.drawimage(i-1, i, 0, 1, sz[1], sz[2], grayGR.(im))
118 end
119 GR.updatews()
84 end 120 end
85 121
86 function visualise(channel_or_toggle, imgs) 122 function visualise(channel_or_toggle, imgs)
87 if isa(channel_or_toggle, Channel) 123 if isa(channel_or_toggle, Channel)
88 rc = channel_or_toggle 124 rc = channel_or_toggle

mercurial