scale_for_display
PURPOSE
[elem_data,ref_lev,max_scale] = scale_for_display( elem_data, pp)
SYNOPSIS
function [elem_data,ref_lev,max_scale] = scale_for_display( elem_data, pp)
DESCRIPTION
CROSS-REFERENCE INFORMATION
This function calls:
This function is called by:
- calc_colours [colours,scl_data]= calc_colours(img, set_value, do_colourbar)
- eidors_colourbar EIDORS_COLOURBAR - create an eidors colourbar with scaling to image
- show_3d_slices show_3d_slices(img, z_cuts, x_cuts, y_cuts, any_cuts)
SOURCE CODE
0001 function [elem_data,ref_lev,max_scale] = scale_for_display( elem_data, pp)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 global eidors_colours;
0026 clim = [];
0027 if nargin <=1
0028 ref_lev = eidors_colours.ref_level;
0029 component = 'real';
0030 elseif ischar(pp) && strcmp(pp, 'use_global' );
0031 ref_lev = eidors_colours.ref_level;
0032 component = 'real';
0033 else
0034 ref_lev = pp.ref_level;
0035 clim = pp.clim;
0036 component = pp.component;
0037 end
0038
0039 if ~isnumeric(ref_lev)
0040 if ~strcmp(ref_lev, 'auto')
0041 error('ref_level parameter must be "auto" or numeric');
0042 end
0043 s_ed= elem_data(:);
0044 s_ed(isnan(s_ed)) = [];
0045 s_ed= sort(s_ed);
0046 e= length(s_ed);
0047 if e==0;
0048 error('Can''t display. All values NaN. Is raw data 0?')
0049 end
0050
0051
0052
0053
0054 rej_vals = floor(.35*e);
0055 ref_lev = mean(s_ed( (rej_vals+1):(end-rej_vals) ));
0056 end
0057
0058 elem_data = elem_data - ref_lev;
0059
0060 switch component;
0061 case 'real'; elem_data = real(elem_data);
0062 case 'imag'; elem_data = imag(elem_data);
0063 otherwise; error('specified component not real or imag');
0064 end
0065
0066 max_scale = max(abs(elem_data(:))) + eps;
0067
0068
0069 if ~isempty(clim)
0070 elem_data( elem_data> clim)= clim;
0071 elem_data( elem_data<-clim)= -clim;
0072 max_scale = clim;
0073 end
0074
0075 if isfield(eidors_colours,'image_field')
0076 elem_data(eidors_colours.image_field_idx) = eidors_colours.image_field_val;
0077 end
0078
0079 elem_data = elem_data/max_scale;
Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005