-
Notifications
You must be signed in to change notification settings - Fork 0
/
image2d.pro
3149 lines (2761 loc) · 99.9 KB
/
image2d.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;*************************************************************************
; Copyright (c) 2002 The University of Chicago, as Operator of Argonne
; National Laboratory.
; Copyright (c) 2002 The Regents of the University of California, as
; Operator of Los Alamos National Laboratory.
; This file is distributed subject to a Software License Agreement found
; in the file LICENSE that is included with this distribution.
;*************************************************************************
@scan_colorbar.pro
@saveImage.pro
@PS_open.pro
PRO image2d_normalize_accept,pick_i,image2d_state
view_option = image2d_state.view_option
view_option.pick_ref = pick_i
view_option.fullcolor = 2
image_array = *image2d_state.image_array
sz = size(image_array)
save_seqno = image2d_state.detector-1
if sz(0) ne 3 then begin
st = 'You have to load the scan # in first'
r = dialog_message(st,/info)
return
end
begin_seqno = 0
end_seqno = sz(3)-1
seqno = begin_seqno + pick_i - 1
if seqno le end_seqno and seqno ge begin_seqno then begin
image2d_state.detector = seqno + 1
; read in ref image
image_ref = image_array(*,*,seqno)
image2d_REPLOT,image2d_state
rmin = MIN(image_ref)
rmax = MAX(image_ref)
view_option.r_k_max = rmax
view_option.r_k_min = rmin
*image2d_state.image = image_ref
endif else begin
st = [ $
'No more image for SCAN #' + string(image2d_state.scanno_current), $
'Total number of images for this scan is ' + $
string(end_seqno - begin_seqno) ]
r = dialog_message(st,/info)
return
end
image2d_state.view_option = view_option
image2d_REPLOT,image2d_state
image2d_state.detector = save_seqno + 1
END
PRO image2d_normalize_Event, Event
COMMON IMAGE2D_NORM_BLOCK, norm_ids
WIDGET_CONTROL,Event.top,GET_UVALUE=norm_state,/no_copy
image2d_state = norm_state.image2d_state
view_option = image2d_state.view_option
widget_ids = image2d_state.widget_ids
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'NORM_PICKED': BEGIN
WIDGET_CONTROL,Event.id,GET_VALUE=i
WIDGET_CONTROL,norm_ids.norm,SET_VALUE=2
image2d_normalize_accept, i,image2d_state
image2d_normalize_setvalue,image2d_state
image2d_REPLOT,image2d_state
END
'NORM_COLOR_SCHEME': BEGIN
view_option.fullcolor = Event.value
if Event.value eq 1 then $
WIDGET_CONTROL,norm_ids.userBase,SENSITIVE=1 else $
WIDGET_CONTROL,norm_ids.userBase,SENSITIVE=0
if view_option.fullcolor lt 2 then begin
; zmin = view_option.k_min
; zmax = view_option.k_max
if view_option.fullcolor eq 1 then begin
zmin = view_option.u_k_min
zmax = view_option.u_k_max
WIDGET_CONTROL,image2d_state.widget_ids.z_min,SET_VALUE=zmin
WIDGET_CONTROL,image2d_state.widget_ids.z_max,SET_VALUE=zmax
end
image2d_state.view_option.fullcolor = view_option.fullcolor
image2d_normalize_setvalue,image2d_state
image2d_REPLOT,image2d_state
endif else begin
WIDGET_CONTROL,norm_ids.pick,GET_VALUE=i
if i gt image2d_state.maxno then begin
st = ['Error: Invalid Normalize Against Image Seq # '+strtrim(i,2), $
' Valid Max Image Seq # is '+strtrim(image2d_state.maxno,2)]
r = dialog_message(st ,/error)
endif else begin
image2d_normalize_accept, i,image2d_state
image2d_normalize_setvalue,image2d_state
if i ne image2d_state.detector then $
image2d_REPLOT,image2d_state
end
end
norm_state.image2d_state = image2d_state
END
'NORM_SLIDER1': BEGIN
WIDGET_CONTROL,Event.Id,GET_VALUE=zmin
image2d_state.view_option.u_k_min = zmin
image2d_state.view_option.fullcolor = 1
WIDGET_CONTROL,image2d_state.widget_ids.z_min,SET_VALUE=zmin
image2d_REPLOT,image2d_state
norm_state.image2d_state = image2d_state
END
'NORM_SLIDER2': BEGIN
WIDGET_CONTROL,Event.Id,GET_VALUE=zmax
image2d_state.view_option.u_k_max = zmax
image2d_state.view_option.fullcolor = 1
WIDGET_CONTROL,image2d_state.widget_ids.z_max,SET_VALUE=zmax
image2d_REPLOT,image2d_state
norm_state.image2d_state = image2d_state
END
'NORM_HELP': BEGIN
st=['Currently, there are three modes of image color scheme available.', $
'It defaults to the Auto Scaled scheme. ', $
'', ' Auto_Scaled - Automatically scaled by the z-max, z-min of the image data.', $
'', ' User_Scaled - User settable interest range of z-min, z-max.', $
'', ' Normalized - Value normalized against the value of the selected image #.', $
'', $
'If the User Scaled color scheme is selected, then a user can directly modify', $
'the Zmin and Zmax fields of the main window or through the lower/upper', $
'bound sliders.', '', $
'If the image sequence # field is entered with a <CR>, it automatically turns on the', $
'normalized color scheme mode. The entered # will be the reference image #.', $
'The normalized value of the reference image itself will be a uniform 1.', $
'', $
'The Done of color scheme dialog resets the image to AutoScaled mode.', '', $
'NOTE: if problem with Normalization encountered, a user can change to',$
' AutoScale or UserScale mode and then re-select the detector from',$
' the detector list to clear the error.','' $
]
res=dialog_message(st,/info,title='Help on Image Color Scheme')
END
'NORM_CANCEL': BEGIN
WIDGET_CONTROL,norm_ids.base,/DESTROY
image2d_state.widget_ids.norm_base = 0L
image2d_state.view_option.fullcolor = 0
norm_ids.base = 0L
norm_ids.userbase = 0L
norm_ids.lb1 = 0L
norm_ids.lb2 = 0L
norm_ids.lb3 = 0L
norm_ids.lb4 = 0L
norm_ids.lb5 = 0L
norm_ids.lb6 = 0L
norm_ids.sldr1 = 0L
norm_ids.sldr2 = 0L
norm_ids.norm = 0L
norm_ids.pick = 0L
image2d_REPLOT,image2d_state
image2d_renew,widget_ids.base
return
END
ENDCASE
widget_control,widget_ids.base,get_uvalue=temp_state,/no_copy
temp_state.view_option.fullcolor = image2d_state.view_option.fullcolor
widget_control,widget_ids.base,set_uvalue=temp_state,/no_copy
WIDGET_CONTROL,norm_state.base,SET_UVALUE=norm_state,/no_copy
END
PRO image2d_renew,wid
widget_control,wid,get_uvalue=image2d_state,/no_copy
widget_ids = image2d_state.widget_ids
image2d_state.widget_ids.norm_base = 0L
image2d_state.view_option.fullcolor = 0
xarr = *image2d_state.xarr
yarr = *image2d_state.yarr
WIDGET_CONTROL, widget_ids.x_min, SET_VALUE=0
WIDGET_CONTROL, widget_ids.y_min, SET_VALUE=0
WIDGET_CONTROL, widget_ids.x_max, SET_VALUE=image2d_state.width-1
WIDGET_CONTROL, widget_ids.y_max, SET_VALUE=image2d_state.height-1
image2d_REPLOT,image2d_state
; set initial xl,xr,yl,yr
WIDGET_CONTROL, widget_ids.x1WID, SET_VALUE=xarr(0)
WIDGET_CONTROL, widget_ids.y1WID, SET_VALUE=yarr(0)
WIDGET_CONTROL, widget_ids.x2WID, SET_VALUE=xarr(image2d_state.width-1)
WIDGET_CONTROL, widget_ids.y2WID, SET_VALUE=yarr(image2d_state.height-1)
widget_control,wid,set_uvalue=image2d_state,/no_copy
END
PRO image2d_normalize_setvalue,image2d_state
COMMON IMAGE2D_NORM_BLOCK, norm_ids
view_option = image2d_state.view_option
mode = 'Normalized Against ...'
if view_option.fullcolor eq 0 then mode = 'Auto Scaled'
if view_option.fullcolor eq 1 then mode = 'User Scaled'
st1='Auto Scaled (Max Value) :' + string(view_option.z_max)
st2='Auto Scaled (Min Value) :' + string(view_option.z_min)
st3='User Scaled (Upper Bound) :' ; + string(view_option.u_k_max)
st4='User Scaled (Lower Bound) :' ; + string(view_option.u_k_min)
st5='Ref Image # '+strtrim(view_option.pick_ref,2) + $
' (Max Value) :' + string(view_option.r_k_max)
st6='Ref Image # '+strtrim(view_option.pick_ref,2) + $
' (Min Value) :' + string(view_option.r_k_min)
WIDGET_CONTROL,norm_ids.lb1,SET_VALUE=st1
WIDGET_CONTROL,norm_ids.lb2,SET_VALUE=st2
WIDGET_CONTROL,norm_ids.lb3,SET_VALUE=st3
WIDGET_CONTROL,norm_ids.lb4,SET_VALUE=st4
WIDGET_CONTROL,norm_ids.lb5,SET_VALUE=st5
WIDGET_CONTROL,norm_ids.lb6,SET_VALUE=st6
END
PRO image2d_normalize, GROUP=Group,image2d_state,title=title
COMMON IMAGE2D_NORM_BLOCK, norm_ids
if n_params() lt 1 then return
if image2d_state.view_option.user eq 0 then begin
st = ['"Image Color Scheme" is available only if','the droplist Pixel is set to the "By User" mode']
r = dialog_message(st,/info)
return
end
if XRegistered('image2d_normalize') then return
view_option = image2d_state.view_option
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
d_title = 'Image Color Scheme'
if keyword_set(title) then d_title = d_title +' ('+title+')'
image2d_normalize = WIDGET_BASE(GROUP_LEADER=Group, $
ROW=1, $
MAP=1, UNAME='image2d_normalize',$
TITLE=d_title, $
UVALUE='image2d_normalize')
BASE2 = WIDGET_BASE(image2d_normalize, $
COL=1, $
MAP=1, $
UVALUE='BASE2')
color_schemes = [ $
'AutoScaled', $
'UserScaled', $
'Normalized' $
]
NORM_COLOR_SCHEME = CW_BGROUP(BASE2, color_schemes, $
ROW=1, /EXCLUSIVE, /NO_RELEASE, $
UVALUE='NORM_COLOR_SCHEME')
norm_min = WIDGET_LABEL( BASE2, $
UVALUE='NORM_MIN', /ALIGN_LEFT,$
VALUE='Auto Scaled (Min Value) :' + string(view_option.z_min))
norm_max = WIDGET_LABEL( BASE2, $
UVALUE='NORM_MAX', /ALIGN_LEFT,$
VALUE='Auto Scaled (Max value) :' + string(view_option.z_max))
BASE5 = WIDGET_BASE( BASE2, COL=1) ;/FRAME)
BASE5_1 = WIDGET_BASE( BASE5, ROW=1) ;/FRAME)
BASE5_2 = WIDGET_BASE( BASE5, ROW=1) ;/FRAME)
norm_lower = WIDGET_LABEL( BASE5_1, $
UVALUE='NORM_LOWER', /ALIGN_LEFT,$
VALUE='User Scaled (Lower Bound) :') ;+ string(view_option.u_k_min))
zmax = view_option.z_max
zmin = view_option.z_min
if zmax eq zmin then begin
zmin = 0
zmax = 255
end
;if view_option.z_max gt view_option.z_min then $
sldr1 = CW_FSLIDER(BASE5_1,MAX=zmax,MIN=zmin, $
value=view_option.z_min,UVALUE='NORM_SLIDER1')
norm_upper = WIDGET_LABEL( BASE5_2, $
UVALUE='NORM_UPPER', /ALIGN_LEFT,$
VALUE='User Scaled (Upper Bound) :') ;+ string(view_option.u_k_max))
;if view_option.z_max gt view_option.z_min then $
sldr2 = CW_FSLIDER(BASE5_2,MAX=zmax,MIN=zmin, $
value=view_option.z_max,UVALUE='NORM_SLIDER2')
BASE3 = WIDGET_BASE( BASE2, COLUMN=1) ;/FRAME)
norm_picked = CW_FIELD( BASE3,VALUE=view_option.pick_ref, $
ROW=1, $
INTEGER=1, /return_events, $
TITLE='Normalize Against Image (Seq+15) #:', XSIZE=2, $
UVALUE='NORM_PICKED')
norm_ref_lower = WIDGET_LABEL( BASE3, $
UVALUE='NORM_LOWER', /ALIGN_LEFT,$
VALUE='Reference (Min Value) :' + string(view_option.r_k_min))
norm_ref_upper = WIDGET_LABEL( BASE3, $
UVALUE='NORM_UPPER', /ALIGN_LEFT,$
VALUE='Reference (Max Value)) :' + string(view_option.r_k_max))
BASE4 = WIDGET_BASE( BASE2, ROW=1)
NORM_HELP = WIDGET_BUTTON( BASE4, $
UVALUE='NORM_HELP', $
VALUE='Help...')
NORM_CANCEL = WIDGET_BUTTON( BASE4, $
UVALUE='NORM_CANCEL', $
VALUE='Done')
image2d_state.widget_ids.norm_base = image2d_normalize
image2d_state.view_option = view_option
norm_ids = { $
base : image2d_normalize, $
userBase : BASE5, $ ; user scaled WID
lb1 : norm_max, $ ; auto max WID
lb2 : norm_min, $ ; auto min WID
lb3 : norm_upper, $ ; user max WID
lb4 : norm_lower, $ ; user min WID
lb5 : norm_ref_upper, $ ; ref upper WID
lb6 : norm_ref_lower, $ ; ref lower WID
sldr1: sldr1, $
sldr2: sldr2, $
norm : norm_color_scheme, $ ; color scheme WID
pick : norm_picked $ ; norm detector WID
}
image2d_state.norm_ids.base = norm_ids.base
image2d_state.norm_ids.userBase = norm_ids.userBase
image2d_state.norm_ids.lb1 = norm_ids.lb1
image2d_state.norm_ids.lb2 = norm_ids.lb2
image2d_state.norm_ids.lb3 = norm_ids.lb3
image2d_state.norm_ids.lb4 = norm_ids.lb4
image2d_state.norm_ids.lb5 = norm_ids.lb5
image2d_state.norm_ids.lb6 = norm_ids.lb6
image2d_state.norm_ids.sldr1 = norm_ids.sldr1
image2d_state.norm_ids.sldr2 = norm_ids.sldr2
image2d_state.norm_ids.norm = norm_ids.norm
image2d_state.norm_ids.pick = norm_ids.pick
WIDGET_CONTROL, norm_ids.norm, SET_VALUE=0
if view_option.fullcolor eq 1 then $
WIDGET_CONTROL, norm_ids.userBase, SENSITIVE=1 else $
WIDGET_CONTROL, norm_ids.userBase, SENSITIVE=0
image2d_normalize_setvalue,image2d_state
norm_state = { base:image2d_normalize, $
norm_ids: norm_ids, $
image2d_state:image2d_state}
WIDGET_CONTROL, image2d_normalize, /REALIZE
WIDGET_CONTROL, image2d_normalize, SET_UVALUE=norm_state,/no_copy
; return,image2d_normalize
XMANAGER, 'image2d_normalize', image2d_normalize , /NO_BLOCK
END
PRO image2d_help,Event
st = ['IMAGE2D - An image array viewing program which allows the user to load 2D', $
'iamge_array directly into IDL', $
'',' *File Menu*','',$
'Save Image for Aim - save 2D image variables accepted by the AIM program', $
'Save as PNG - save TV image as IDL PNG file', $
'Save as TIFF - save TV image as IDL TIFF file in reverse order', $
'Save as XDR - save 2D image, X,Y,Z ranges in XDR format', $
'Printer... - dialog to override the default printer', $
'Print - send TV plot to PS plotter device', $
'PS_close - close the PS plotter device', $
'Quit - quit the IMAGE2D program', $
'',' *Color Menu*','',$
'Save Private Color Table - save current color table as private', $
'Load Private Color Table - load the saved private color table into IDL', $
'Image Color Scheme... - dialog for using user adjustable color scheme', $
'Change Color Table... - dialog for selecting various IDL color tables', $
'',' *Help*', '',$
'Help... - gives this help info page', $
'',' *View as Menu*', '',$
'Log Off/On - color scale in linear of logarithm', $
'TV - display 2D data as scaled TV iamge', $
'Eq.TV.AspRt - display 2D data with equal X,Y axis aspect ratio', $
'LIGHT_SHADE_SURF - display 2D data as light shade surface plot', $
'CONTOUR - display 2D data as equal contour line plot', $
'SHOW3 - show data as image, surface, and equal contour plot', $
'PLOT2D... - use PLOT2D program to display 2D image data', $
'SHADE_SURF - display 2D data as shade surface plot', $
'',' *Pixel Menu*','', $
'By Image - display actual 2D data image without scaling', $
'By User - pixel automatically re-sized by user data (default)', $
'',' *Plot vs Menu*','', $
'Step # - step # used in X, Y axis plot', $
'Values - real values used in X, Y axis plot (default)', $
'',' *ASCII Report*','', $
'ASCII... - termial window display ascii image data', $
'Format - text field controls the ascii data format', $
'',' *Image Selection*','', $
'ReNew - Refresh TV image as re-selected the 2D image', $
'D01-D70 List - Detector D01-D70 selection list', $
'D1-DF List - Detector D1-DF selection list', $
'',' *Drawing Area Events*','', $
'Lelf Mouse Button - button 1 (LMB) updates cursor X,Y,Z field values', $
'Middle Mouse Button - button 2 (MMB) pops up profile lines at the cursor position',$
'Right Mouse Button - button 3 (RMB) zoomin box and updates XL,XR,YL,YR fields', $
'',' *Set New Scan Ranges*','', $
'Set New 2D Scan Ranges - accepts XL,XR,YL,YR values and calls the caput process ',$
' to set as the new 2D scan ranges', $
'',' *PanImages Menu*','', $
'PanImages... - pops up PanImage program', $
'Calibration... - pops up calibration program', $
'',' *Fitting Menu*','', $
'Ez_Fit... - pops up EZ_FIT program with TV image data', $
'2D Binary - saves TV image as EZ_FIT 2D binary data ', $
'',' *2D-ROI Menu*','', $
'Help... - pops up help info for 2D-ROI program', $
'ROI... - pops up 2D ROI program',$
'Type subMenu - sets the type of ROI defined', $
' RectROI - rectangular ROI',$
' FilterROI - filter ROI (lower and upper bound)',$
' PolyROI - polygon ROI',$
'AppendRpt... - dialog append ROI report to old report file', $
'ReplaceRpt... - dialog replace an old report file', $
'ViewRpt... - dialog display the ROI report file', $
'RenameRpt... - dialog to rename ROI report', $
'',' *Ranges Text Fields*','', $
'Xmin - image starting X index', $
'Xmax - image ending X index', $
'Ymin - image starting Y index', $
'Ymax - image ending Y index', $
'Zmin - image Z value lower bound', $
'Zmax - image Z value upper bound', $
'',' *Info Text*','', $
'Display image summary information' $
]
xdisplayfile,text=st,Group=Event.top
END
PRO image2d_ROIRpt,image2d_state,Ref=Ref,roifile=roifile,rptfile=rptfile,header=header,comment=comment,append=append
COMMON STATISTIC_2DBLOCK, statistic_2dids
print,'statistic_2dids.back=',statistic_2dids.back
seq = image2d_state.scanno_current
if image2d_state.maxno le 0 then begin
res=WIDGET_MESSAGE('Error: no image file loaded in')
return
end
image_array = *image2d_state.image_array
xarr = *image2d_state.xarr
yarr = *image2d_state.yarr
def = image2d_state.id_def
nodet = n_elements(def)
xdim = image2d_state.width
ydim = image2d_state.height ;catch2d_file.y_req_npts
scanno_2d = seq
; panimage,da2d,def
; pops up roi images
update:
header_ass = ''
comment_ass = ''
if keyword_set(header) then header_ass=header
if keyword_set(comment) then comment_ass=comment
pick = 1
if keyword_set(ref) then pick=ref
if pick gt 0 and pick le nodet then im_ref = image_array(*,*,pick-1) else begin
res = dialog_message('Invalid reference detector # picked',/error)
return
end
reportname =image2d_state.view_option.rptfile; 'tmproi.rpt'
if keyword_set(rptfile) then reportname=rptfile
if image2d_state.view_option.roifile eq '' then begin
f = dialog_pickfile(path=statistic_2dids.roipath,filter='*roi.xdr*',title='Pick ROI definition File',/READ)
if f eq '' then return
found = findfile(f)
if found(0) eq '' then begin
res = dialog_message(['Filename:',f, 'not found!'],/info)
return
end
image2d_state.view_option.roifile = f
end
; read roi
xrange=[0,xdim-1]
yrange=[0,ydim-1]
filename=image2d_state.view_option.roifile ; 'tmproi.xdr'
if keyword_set(roifile) then filename=roifile
if statistic_2dids.back eq 2 then filename=filename+'.poly'
found = findfile(filename)
if found(0) eq '' then begin
res = dialog_message(['ROI filename',filename, 'not found.', $
'','The whole 2D region is assumed'],/info)
endif else begin
if statistic_2dids.back eq 0 then begin
xdr_open,unit,filename
xdr_read,unit,x
xdr_close,unit
xrange=fix([x(0)/x(4),x(1)/x(4)])
yrange=fix([x(2)/x(5),x(3)/x(5)])
end
if statistic_2dids.back eq 1 then begin
lower_b = statistic_2dids.backave
upper_b = statistic_2dids.backave2
end
if statistic_2dids.back eq 2 then begin
statistic_2dReadPolyROI,statistic_2dids,xverts,yverts,xv,yv,arr
end
end
if xrange(1) ge xdim then xrange(1) = xdim -1
if yrange(1) ge ydim then yrange(1) = ydim -1
if statistic_2dids.refresh eq 1 then begin
xrange= statistic_2dids.xrange
yrange= statistic_2dids.yrange
end
if keyword_set(append) then $
openw,1,reportname,ERROR=err,/append else $
openw,1,reportname,ERROR=err
IF (err NE 0) then begin
PRINTF, -2, !ERR_STRING
close,1
return
end
printf,1,'===================================================='
printf,1,'Generated at: ',systime(0)
printf,1,'Header: ',header_ass
printf,1,'Comment: ',comment_ass
if statistic_2dids.refresh eq 0 then $
printf,1,'ROIfile: ',filename else $
printf,1,'ROIfile: [Temporary ROI specified]'
printf,1,''
for i=0,nodet-1 do begin
if def(i) then begin
;
printf,1,'Detector #: ', i+1
im = image_array(*,*,i)
if keyword_set(ref) then im = image_array(*,*,i)/im_ref
if statistic_2dids.back eq 2 then begin
nelem = n_elements(arr)
if nelem eq 0 then begin
r = dialog_message('You have to define the POLYGON ROI first',/info)
return
end
temp = make_array(nelem)
for ij=0,nelem-1 do begin
j = arr(ij) / xdim
k = arr(ij) MOD xdim
temp(ij) = im(k,j)
end
endif else begin
nelem = (xrange(1)-xrange(0)+1)*(yrange(1)-yrange(0)+1)
temp = im[xrange(0):xrange(1),yrange(0):yrange(1)]
end
result = moment(temp,mdev=mdev,sdev=sdev)
temp_max = max(temp)
temp_min = min(temp)
total = total(temp)
ave = result[0]
; write report
if statistic_2dids.back eq 2 then begin
printf,1,'ROI defined by polygon'
printf,1,'Xverts index:',xv
printf,1,'Yverts index:',yv
endif else begin
printf,1,'ROI in index: [',strtrim(xrange(0),2),':', $
strtrim(xrange(1),2),', ', $
strtrim(yrange(0),2),':', $
strtrim(yrange(1),2),'] '
printf,1,'ROI in values: [',strtrim(xarr(xrange(0)),2),':', $
strtrim(xarr(xrange(1)),2),', ', $
strtrim(yarr(yrange(0)),2),':', $
strtrim(yarr(yrange(1)),2),'] '
end
printf,1,'ave = ',ave
printf,1,'dev = ',sdev
printf,1,'min = ',temp_min
printf,1,'max = ',temp_max
printf,1,'total = ',total
printf,1,'nelem = ',nelem
printf,1,''
end
end
close,1
xdisplayfile,reportname
END
PRO PDMENU99_ROI_event, Event, image2d_state
COMMON STATISTIC_2DBLOCK, statistic_2dids
view_option = image2d_state.view_option
widget_ids = image2d_state.widget_ids
image_array = *image2d_state.image_array
xarr = *image2d_state.xarr
yarr = *image2d_state.yarr
x = xarr(0:image2d_state.width-1)
y = yarr(0:image2d_state.height-1)
im=image_array(*,*,image2d_state.detector-1)
if n_elements(im) eq 0 then begin
r = dialog_message(['No image data found','','You have to load the 2D data first'],/info)
return
end
header=[ image2d_state.path+!os.file_sep+image2d_state.name, $
', Detector # '+ strtrim(image2d_state.detector,2) + ' ('+ $
image2d_state.DPVS(image2d_state.detector-1)+')']
comment=''
if view_option.fullcolor eq 2 then $
comment='Normalized against detecor '+strtrim(view_option.pick_ref,2)
if XRegistered('scan2d_ROI') then $
WIDGET_CONTROL,statistic_2dids.base,/DESTROY,BAD=bad
mode=0
if n_elements(statistic_2dids) then begin
mode = statistic_2dids.back
if image2d_state.view_option.roifile ne statistic_2dids.file then $
image2d_state.view_option.roifile = statistic_2dids.file
if image2d_state.view_option.rptfile ne statistic_2dids.rpt then $
image2d_state.view_option.rptfile = statistic_2dids.rpt
end
if image2d_state.view_option.rptfile eq '' then $
image2d_state.view_option.rptfile = image2d_state.home+!os.file_sep+'ROI'+!os.file_sep+$
image2d_state.name+'_roi.rpt'
if image2d_state.view_option.roifile eq '' then $
image2d_state.view_option.roifile = image2d_state.home+!os.file_sep+'ROI'+!os.file_sep+$
image2d_state.name+'_roi.xdr'
if n_elements(statistic_2dids) eq 0 then $
scan2d_roi,im,x,y,GROUP=Event.Top,header=header,comment=comment, $
mode=mode,rptfile=image2d_state.view_option.rptfile, $
roifile=image2d_state.view_option.roifile,roi_data=statistic_2dids
CASE Event.Value OF
'2D-ROI.Type.RectROI': BEGIN
statistic_2dids.back = 0
return
END
'2D-ROI.Type.FilterROI': BEGIN
statistic_2dids.back = 1
return
END
'2D-ROI.Type.PolyROI': BEGIN
statistic_2dids.back = 2
return
END
'2D-ROI.AppendRpt...': BEGIN
; image2d_state.view_option.rptfile = f
if statistic_2dids.comment ne '' then comment=statistic_2dids.comment
if image2d_state.view_option.fullcolor eq 2 then $
image2d_ROIRpt,image2d_state, $
header=header, comment=statistic_2dids.comment, $
Ref=image2d_state.view_option.pick_ref, /append else $
image2d_ROIRpt,image2d_state, $
header=header, comment=statistic_2dids.comment, /append
END
'2D-ROI.ReplaceRpt...': BEGIN
F = image2d_state.view_option.rptfile
; f = dialog_pickfile(path=statistic_2dids.rptpath,filter='*rpt*',title='Replace ROI Rpt File',/READ)
if f eq '' then return
found = findfile(f)
if found(0) eq '' then begin
res = dialog_message(['Filename:',f, 'not found will be created!'],/info)
endif else begin
st = ['Are you sure you want to overwrite this file ?', $
'If you enter Yes, then all the old text contents', $
'in this file will be lost.', $
'','Replacing ',F , ' ???']
res = dialog_message(st,/question)
if res eq 'No' then return
end
; image2d_state.view_option.rptfile = f
if statistic_2dids.comment ne '' then comment=statistic_2dids.comment
if image2d_state.view_option.fullcolor eq 2 then $
image2d_ROIRpt,image2d_state, $
header=header, comment=statistic_2dids.comment, $
Ref=image2d_state.view_option.pick_ref else $
image2d_ROIRpt,image2d_state, $
header=header, comment=statistic_2dids.comment
END
'2D-ROI.ViewRpt...': BEGIN
f = dialog_pickfile(path=statistic_2dids.rptpath,filter='*rpt*',title='View ROI Rpt File',/READ)
if f eq '' then return
found = findfile(f)
if found(0) eq '' then begin
res = dialog_message(['Filename:',f, 'not found!'],/info)
return
end
; image2d_state.view_option.rptfile = f
xdisplayfile,f
END
'2D-ROI.RenameRpt...': BEGIN
old = image2d_state.view_option.rptfile
rename_dialog,image2d_state.home+!os.file_sep+'ROI',old,'',GROUP=Event.top
END
'2D-ROI.ROI...': BEGIN
scan2d_roi,im,x,y,GROUP=Event.Top,header=header,comment=comment, $
mode=mode,rptfile=image2d_state.view_option.rptfile, $
roifile=image2d_state.view_option.roifile,roi_data=statistic_2dids
END
'2D-ROI.Help...': BEGIN
st = [ $
'In general the 2D ROI reports generated by 2D-ROI menu',$
'in Image2d consist of all detectors defined in a given 2D scan.', $
'',$
' Options of 2D-ROI Menu', '', $
'Help... - Show this help info ', $
'ROI... - Pops up 2D Statistic ROI program', $
'Type->RectROI - Set the type of ROI used in the summary report', $
' FilterROI', $
' PolyROI', $
'AppendRpt... - Append 2D statistic summary report of all', $
' detectors to the report file', $
' for a given 2D scan ROI',$
'ReplaceRpt... - Overwrite 2D statistic report file', $
' with the summary of all the detectors', $
' with ROI as show in 2D Statistic ROI window',$
'ViewRpt... - Select and view any 2D statistic report', $
'RenameRpt... - Rename the rpt file to a new name', '',$
'',$
'If the detailed 2D ROI reports for a specified detector, or', $
'refining of the ROI are desired, a user should run the ',$
'"2D Statistic ROI" program first which can be brought up by ', $
'',' 2D-ROI->ROI... ', '', $
'The AppendRep... button in "2D Statistic ROI" window generates ', $
'detail report for the displayed image.', '', $
'For file management simplicity the 2D ROI statistic report ', $
'should end with roi.rpt and the region of interest file ',$
'for rectangle or polygon ROI should end with roi.xdr ' $
]
xdisplayfile,text=st,title='Image2d Help on 2D-ROI'
END
ENDCASE
END
PRO image2d_datatotext,image2d_state
COMMON IMAGE2D_NORM_BLOCK, norm_ids
widget_ids = image2d_state.widget_ids
view_option = image2d_state.view_option
image_array = *image2d_state.image_array
xarr = *image2d_state.xarr
yarr = *image2d_state.yarr
if view_option.user then begin
widget_control,widget_ids.x_min,get_value=x1
widget_control,widget_ids.x_max,get_value=x2
widget_control,widget_ids.y_min,get_value=y1
widget_control,widget_ids.y_max,get_value=y2
image2d_state.view_option.x_min = x1
image2d_state.view_option.y_min = y1
image2d_state.view_option.x_max = x2
image2d_state.view_option.y_max = y2
image = image_array(x1:x2,y1:y2,image2d_state.detector-1)
px = xarr(x1:x2)
py = yarr(y1:y2)
endif else begin
image = image_array(*,*,image2d_state.detector-1)
px =xarr
py =yarr
end
;reset for user range
;norm_ids = image2d_state.norm_ids
if XRegistered('image2d_normalize') then begin
if norm_ids.norm then begin
widget_control,norm_ids.norm,get_value=n1
widget_control,norm_ids.pick,get_value=n2
image2d_state.view_option.fullcolor = n1
image2d_state.view_option.pick_ref = n2
endif else begin
image2d_state.norm_ids.userBase = 0L
image2d_state.norm_ids.lb1 = 0L
image2d_state.norm_ids.lb2 = 0L
image2d_state.norm_ids.lb3 = 0L
image2d_state.norm_ids.lb4 = 0L
image2d_state.norm_ids.lb5 = 0L
image2d_state.norm_ids.lb6 = 0L
image2d_state.norm_ids.norm = 0L
image2d_state.norm_ids.pick = 0L
image2d_state.widget_ids.norm_base = 0L
image2d_state.view_option.fullcolor = 0
image2d_state.view_option.pick_ref = 1
end
end
;print,'fullcolor=',image2d_state.view_option.fullcolor,' pick_ref=',image2d_state.view_option.pick_ref
if image2d_state.view_option.fullcolor eq 2 then begin
image_ref = *image2d_state.image
image = image/ image_ref(x1:x2,y1:y2)
end
sz = size(image)
image2d_state.width = sz(1)
image2d_state.height = sz(2)
dir = image2d_state.outpath+'ASCII'+!os.file_sep
found = findfile(dir,count=ct)
if ct lt 1 then spawn,!os.mkdir + ' ' +dir
detector = image2d_state.detector
suf0 = strsplit(image2d_state.DPVS(detector-1),':',/extract)
file = image2d_state.name +'_im'+ suf0[0]
report = dir+file
image2d_writeImage,image2d_state,image,px,py,detector-1,report
xdisplayfile,report
END
PRO show_cross,x,y,d_id,s_id
if n_params() lt 4 then begin
print,'Usage: show_cross,x,y,d_wid,s_wid
print,' x, y - specify cross hair coordinate
print,' d_win - specify tv image window
print,' s_win - saved virtual image window
return
end
CATCH,error_status
if error_status eq -324 then begin
print,!err_string
print,'Invalid window id : ', s_id
return
end
WSET,s_id
width = !d.x_size
height = !d.y_size
WSET,d_id
xa = [0,width-1]
ya = [y,y]
plots,xa,ya,/device
xa = [x,x]
ya = [0,height-1]
plots,xa,ya,/device
END
PRO hide_cross,x,y,d_id,s_id
if n_params() lt 4 then begin
print,'Usage: hide_cros,x,y,d_wid,s_wid
print,' x, y - specify cross hair coordinate
print,' d_win - specify tv image window
print,' s_win - saved virtual image window
return
end
CATCH,error_status
if error_status eq -324 then begin
print,!err_string
print,'Invalid window id : ', s_id
return
end
WSET,s_id
width = !d.x_size
height = !d.y_size
WSET,d_id
if x ge 0 and x lt width then $
device,copy=[x,0,1,height,x,0,s_id]
if y ge 0 and y lt height then $
device,copy=[0,y,width,1,0,y,s_id]
END
PRO update_pixmap,wid
o_wid = !d.window
if !d.n_colors eq 16777216 then channel=1 else channel=0
data = TVRD(TRUE=channel)
WSET,wid
TV,data,TRUE=channel
WSET,o_wid
END
PRO create_pixmap,wid,data=data,xp=xp,yp=yp,width=width,height=height
if n_params() lt 1 then begin
print,'Usage: create_pixmap,wid
print,' output - wid , saved virtual image window id
print,' keyword - xp,yp, width,height
print,'Save the whole TV window to a new virtual window
print,' if keyword is used all four of them must be specified
return
end
if !d.n_colors eq 16777216 then data = TVRD(TRUE=1) else $
data = TVRD(TRUE=0)
if keyword_set(xp) and keyword_set(yp) and keyword_set(width) $
and keyword_set(height) then begin
if !d.n_colors eq 16777216 then $
newdata = data(0:2, xp:xp+width-1, yp:yp+height-1) else $
newdata = data(xp:xp+width-1, yp:yp+height-1)
data = newdata
end
ss = size(data)
if ss(0) eq 2 then begin
xs = ss(1)
ys = ss(2)
channel = 0
end
if ss(0) eq 3 and ss(1) eq 3 then begin
xs = ss(2)
ys = ss(3)
channel = 1
end
if !d.n_colors eq 16777216 then $
print,'CREATE PIXMAP: Array(3,',strtrim(xs,2),',',strtrim(ys,2),')' else $
print,'CREATE PIXMAP: Array(',strtrim(xs,2),',',strtrim(ys,2),')'
window,/free,/pixmap, xsize=xs, ysize=ys
wid= !d.window
TV,data,TRUE=channel
END
PRO image2d_REPLOT,image2d_state
COMMON SYSTEM_BLOCK,OS_SYSTEM
COMMON COLORBAR, colorbar_data
COMMON PRINTER_BLOCK,printer_info
COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
COMMON IMAGE2D_NORM_BLOCK, norm_ids
if n_elements(colorbar_data) eq 0 then colorbar_init,colorbar_data
widget_ids = image2d_state.widget_ids
view_option = image2d_state.view_option
image_array = *image2d_state.image_array
px = *image2d_state.xarr
py = *image2d_state.yarr
if XRegistered('image2d_normalize') then begin
if norm_ids.norm gt 0L then begin
widget_control,norm_ids.norm,get_value=n1
widget_control,norm_ids.pick,get_value=n2
image2d_state.view_option.fullcolor = n1
image2d_state.view_option.pick_ref = n2
endif else begin
image2d_state.view_option.fullcolor = 0
image2d_state.view_option.pick_ref = 16 ;1
end
endif else begin
image2d_state.view_option.fullcolor = 0
image2d_state.view_option.pick_ref = 16 ;1
end
;print,'fullcolor=',image2d_state.view_option.fullcolor,' pick_ref=',image2d_state.view_option.pick_ref
if view_option.user then begin
widget_control,widget_ids.x_min,get_value=x1
widget_control,widget_ids.x_max,get_value=x2
widget_control,widget_ids.y_min,get_value=y1
widget_control,widget_ids.y_max,get_value=y2
image2d_state.view_option.x_min = x1
image2d_state.view_option.y_min = y1
image2d_state.view_option.x_max = x2
image2d_state.view_option.y_max = y2
image = image_array(x1:x2,y1:y2,image2d_state.detector-1)
xarr = px(x1:x2)
yarr = py(y1:y2)
endif else begin