forked from ChrisBeaumont/beaumont-idl-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvblink.pro
85 lines (74 loc) · 2.17 KB
/
tvblink.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;+
; NAME:
; TVBLINK
;
; PURPOSE:
; Blink between several images, without having to manually set up the
; plotting windows.
;
; Category:
; Display utilities
;
; PROCEDURE:
; This is a wrapper routine for the BLINK procedure in the IDL
; Astronomy User's library. TVBLINK goes through the work of
; creating, displaying, and destroying the image windows which are
; blinked between.
;
; CALLING SEQUENCE:
; TVBLINK, image1, image2, [image3, ... image5,
; delay = delay, /scale]
;
; INPUTS:
; image1: 2D image array to flip through
; image2: 2D image array to flip through
; image3: 2D image array to flip through
; image4: 2D image array to flip through
; image5: 2D image array to flip through
;
; KEYWORD PARAMETERS:
; DELAY: The time delay, in seconds, between blinking
; SCALE: If set, the input images are auto-stretched
;
; SIDE EFFECTS:
; Temporary plotting windows are created, and images are blinked on
; the screen.
;
; PROCEDURES CALLED:
; BLINK (IDL Astro Library)
; TVIMAGE (David Fanning's Coyote Library)
;
; MODIFICATION HISTORY:
; Written by: Chris Beaumont, December 2008
;-
PRO tvblink, image1, image2, image3, image4, image5, SCALE=scale, DELAY=delay
compile_opt idl2
on_error, 2
;-save initial device information
win0 = !d.window
!p.multi = 0
;- check for inputs
nimage = n_params()
if nimage lt 2 || nimage gt 5 then begin
print, 'TVBLINK calling sequence: '
print, 'TVBLINK, image1, image2, [image3 ... image5,'
print, ' /SCALE, delay = delay'
return
endif
;- array to hold which windows we create
winID = intarr(nimage)
;- get image dimensions, create a new window, and plot
for i = 0, nimage-1, 1 do begin
iPlusStr = strtrim(i+1, 2)
tmp = execute('sz = size(image'+ iPlusStr +')')
if sz[0] ne 2 then message, 'Input images must be 2D arrays'
window, /free, xsize=sz[1], ysize=sz[2], /pixmap, retain = 2
winID[i] = !d.window
tmp = execute('tvimage, image' + iPlusStr + ', scale=keyword_set(scale)')
endfor
if keyword_set(delay) then blink, winID, delay $
else blink, winID
;-erase windows, restore original window
for i = 0, n_elements(winID)-1, 1 do wdelete, winID[i]
if (win0 ne -1) then wset, win0
end