;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Name: ; disp_sav2.pro ; ; Purpose: ; This program opens image files (written by means of the writedata.pro ; by Thomas Boerner), displays them and plots the corresponding histograms. ; It also allows to save what has been created as .eps files without ; worrying of resizing. ; ; Problems: ; Especially when trying to display 3 images as an RGB composite there could ; be problems in allocating the memory. ; ; ; Author: ; Vito Alberga ; (Auxiliary programs by Thomas Boerner and David Fanning have been also used). ; ; Date: ; October 1999 (revised on February, June and December 2000) ; ; Calling sequence: ; disp_sav2 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pro disp_sav2 path_eps = 'd:'; Location of the .eps file to be saved. ximage = 512 ; Dimensions of the images to display. yimage = 512 ; Choose a color table from the list. device, decomposed = 0 ; This command is just to obtain a display on the screen of the color tables. xloadct, /block device, decomposed = 1 tvlct, r, g, b, /get ; Choose whether read one or three files containing each a single image. read, prompt = 'How many images do you want to display as a RGB composite, 1 or 3? ', ask_read case ask_read of 1: begin x_win = 650 ; Dimensions of the image window to be opened y_win = 550 ; Read a single-image file, determine what kind of data type contains and, in the case of ; complex datasets, calculate the module. readmem, data details = size(data) case details[3] of 1: im = data ; byte 2: im = data ; integer 3: im = data ; long 4: im = data ; float 5: im = data ; double 6: im = abs(data) ; complex 9: im = abs(data) ; dcomplex endcase minim = min(im, MAX = maxim, /NAN ) print, 'min =', minim print, 'max =', maxim result = MOMENT(im, /nan ) PRINT, 'Mean =', result[0] PRINT, 'Standard dev. =', sqrt(result[1]) INDEX_im = WHERE( finite(im) eq 0, count_im) if count_im eq 0 then begin isim = hist_equal(im) endif else begin im(INDEX_im) = 0. isim = hist_equal(im) endelse rest1 = (details[1] mod ximage) rest2 = (details[2] mod yimage) if (rest1 eq 0) and (rest2 eq 0) then begin risim = rebin(isim, ximage, yimage) endif else begin risim = congrid(isim, ximage, yimage) endelse ; Prepare the display as a RGB image using the chosen color table. risim24 = bytarr(ximage, yimage, 3) risim24[*, *, 0] = r(risim) risim24[*, *, 1] = g(risim) risim24[*, *, 2] = b(risim) ; Draw the correspondig histogram. window, /free hist_tot, im, result, minim, maxim ; Open a window and, by means of the tvimage program and of one of the *_colorbar.pro, display the ; image and the colorbar associated to the chosen color table with the corresponding values. window, /free, xsize = x_win, ysize = y_win ; Relative positions with the colorbar to the left of the image: ;imageposit = [0.2, 0.2, 0.95, 0.95] ;cbposition = [0.15, 0.2, 0.18, 0.95] ; Relative positions with the colorbar to the right of the image: xi = (11.0/13) x1cb = (11.1/13) x2cb = (11.6/13) imageposit = [0, 0, xi , 1];[0.05, 0.2, 0.8, 0.95]; cbposition = [x1cb, 0, x2cb, 1];[0.82, 0.2, 0.85, 0.95]; ; Relative positions with the colorbar under the image: ;imageposit = [0.2, 0.2, 0.95, 0.95] ;cbposition = [0.2, 0.15, 0.95, 0.18] ; Define the range of the colorbar. read, prompt = 'Insert minimum colorbar value: ',in_min read, prompt = 'Insert maximum colorbar value: ',in_max cbrange = [in_min, in_max] ; Define the title of the colorbar. cbtit = '' read, cbtit, prompt = 'Choose a title for the colorbar: ' tvimage, risim24, true = 3, position = imageposit, /KEEP_ASPECT_RATIO ; Display the image. ;left_colorbar, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit ; Display the colorbar. right_colorbar, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit ;horiz_colorbar, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit ; Choose whether print image and plot to file (encapsulated postscript with preview option) using ; the tvimage program. here = !d.name read, prompt = 'Do you like the image? Do you want to print to file? (yes=1 / no=0) ', ask_print case ask_print of 1: begin set_plot, 'PS' device, color = 1, bits_per_pixel = 8 device, /encapsulated, /preview device, filename = dialog_pickfile( path = path_eps, filter = '*.eps' ) print, 'Choose a name for the image file' tvimage, risim24, true = 3, position = imageposit, /KEEP_ASPECT_RATIO ;print_l_cb, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit print_r_cb, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit ;print_h_cb, cbrange, cb24, POSITION = cbposition, CB_TITLE = cbtit device, /close_file set_plot, here end else: endcase read, prompt = 'Do you like the plot? Do you want to print to file? (yes=1 / no=0) ', ask_print case ask_print of 1: begin set_plot, 'PS' device, color = 1, bits_per_pixel = 8 device, /encapsulated, /preview device, filename = dialog_pickfile( path = path_eps, filter = '*.eps') print, 'Choose a name for the plot file' hist_tot, im, result, minim, maxim device, /close_file set_plot, here end else: endcase end 3: begin x_win = 650 ; Dimensions of the image window to be opened y_win = 650; ; Read three single-image files, determine what kind of data type contain and, in the case of ; complex datasets, calculate the module. readmem, data1 ; 1st image. details1 = size(data1) case details1[3] of 1: im1 = data1 ; byte 2: im1 = data1 ; integer 3: im1 = data1 ; long 4: im1 = data1 ; float 5: im1 = data1 ; double 6: im1 = abs(data1) ; complex 9: im1 = abs(data1) ; dcomplex endcase min1 = min(im1, MAX = max1, /NAN ) print, 'min R =', min1 print, 'max R =', max1 rest1 = (details1[1] mod ximage) rest2 = (details1[2] mod yimage) if (rest1 eq 0) and (rest2 eq 0) then begin risim1 = rebin(im1, ximage, yimage) endif else begin risim1 = congrid(im1, ximage, yimage) endelse readmem, data2 ; 2nd image. details2 = size(data2) case details2[3] of 1: im2 = data2 ; byte 2: im2 = data2 ; integer 3: im2 = data2 ; long 4: im2 = data2 ; float 5: im2 = data2 ; double 6: im2 = abs(data2) ; complex 9: im2 = abs(data2) ; dcomplex endcase min2 = min(im2, MAX = max2, /NAN ) print, 'min G =', min2 print, 'max G =', max2 if (rest1 eq 0) and (rest2 eq 0) then begin risim2 = rebin(im2, ximage, yimage) endif else begin risim2 = congrid(im2, ximage, yimage) endelse if ( total(details1) eq total(details2) ) then begin readmem, data3 ; 3rd image. details3 = size(data3) case details3[3] of 1: im3 = data3 ; byte 2: im3 = data3 ; integer 3: im3 = data3 ; long 4: im3 = data3 ; float 5: im3 = data3 ; double 6: im3 = abs(data3) ; complex 9: im3 = abs(data3) ; dcomplex endcase min3 = min(im3, MAX = max3, /NAN ) print, 'min B =', min3 print, 'max B =', max3 if (rest1 eq 0) and (rest2 eq 0) then begin risim3 = rebin(im3, ximage, yimage) endif else begin risim3 = congrid(im3, ximage, yimage) endelse if ( total(details2) eq total(details3) ) then begin ; Prepare the display as a RGB image using the chosen color table. risim24 = hist_equal([[[risim1]], [[risim2]], [[risim3]]]) ; Open a window and, by means of the tvimage program, display it. window, /free, xsize = x_win, ysize = y_win imageposit = [0, 0, 1, 1];[0.05, 0.05, 0.95, 0.95] tvimage, risim24, true = 3, /KEEP_ASPECT_RATIO, position = imageposit ; Choose whether print the image to file (encapsulated postscript with preview option) using ; the tvimage program. here = !d.name read, prompt = 'Do you like the image? Do you want to print to file? (yes=1 / no=0) ', ask_print case ask_print of 1: begin set_plot, 'PS' device, color = 1, bits_per_pixel = 8 device, /encapsulated, /preview device, filename = dialog_pickfile( path = path_eps, filter = '*.eps' ) print, 'Choose a name for the image file' tvimage, risim24, true = 3, /KEEP_ASPECT_RATIO, position = imageposit device, /close_file set_plot, here end else: endcase endif else begin print, 'Dimensions of the images not coincident' endelse endif else begin print, 'Dimensions of the images not coincident' endelse end endcase end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;