repaint_inho

PURPOSE ^

function repaint_inho(mat,mat_ref,vtx,simp, thresh);

SYNOPSIS ^

function repaint_inho(mat,mat_ref,vtx,simp, thresh, clr_def);

DESCRIPTION ^

function repaint_inho(mat,mat_ref,vtx,simp, thresh);

Repaints the simulated inhomogeneity according to the reference
distribution. (Increase -> Red, Decrease -> Blue) 

mat     = The simulated (targeted) distribution.
mat_ref = The known initial (homogeneous) distribution.
        = Override default unless 'use_global'
vtx     = The vertices matrix.
simp    = The simplices matrix.
thresh  = Threshold to show imaged region (or [] for default)
clr_def = Colour definitions val.calc_colours.field etc

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function repaint_inho(mat,mat_ref,vtx,simp, thresh, clr_def);
0002 %function repaint_inho(mat,mat_ref,vtx,simp, thresh);
0003 %
0004 %Repaints the simulated inhomogeneity according to the reference
0005 %distribution. (Increase -> Red, Decrease -> Blue)
0006 %
0007 %mat     = The simulated (targeted) distribution.
0008 %mat_ref = The known initial (homogeneous) distribution.
0009 %        = Override default unless 'use_global'
0010 %vtx     = The vertices matrix.
0011 %simp    = The simplices matrix.
0012 %thresh  = Threshold to show imaged region (or [] for default)
0013 %clr_def = Colour definitions val.calc_colours.field etc
0014 
0015 % (C) 2005 Andy Adler + Nick Polydorides. License: GPL version 2 or version 3
0016 % $Id: repaint_inho.m 2769 2011-07-14 16:44:49Z aadler $
0017 
0018 if nargin<5
0019     thresh = [];
0020 end
0021 if nargin<6
0022     clr_def = [];
0023 end
0024 if strcmp(mat_ref, 'use_global')
0025    img.calc_colours.ref_level = mat_ref;
0026 end
0027 
0028 if isempty(thresh)
0029     thresh = 1/4;
0030 end
0031 
0032 % looks best if eidors_colours.greylev < 0
0033 [colours,scl_data] = calc_colours( mat, clr_def, 0);
0034 ii=find( abs(scl_data) > thresh);
0035 this_x = simp(ii,:);
0036 
0037 colours= permute(colours(ii,:,:),[2,1,3]);
0038 ELEM= vtx';
0039 
0040 Xs=   zeros(3,length(ii));
0041 Ys=   zeros(3,length(ii));
0042 Zs=   zeros(3,length(ii));
0043 switch(size(this_x,2))
0044     case 3
0045         idx_ = [1;2;3];
0046     case 4
0047         idx_ = [[1;2;3], ...
0048                 [1;2;4], ...
0049                 [1;3;4], ...
0050                 [2;3;4]];
0051 end
0052 for idx=idx_
0053    Xs(:)=vtx(this_x(:,idx)',1);
0054    Ys(:)=vtx(this_x(:,idx)',2);
0055    Zs(:)=vtx(this_x(:,idx)',3);
0056 
0057    if exist('OCTAVE_VERSION');
0058 % TODO: This is really slow, can we do anything about it
0059       cmap = colormap;
0060       for i=1:size(colours,2);
0061          patch(Xs(:,i),Ys(:,i),Zs(:,i),cmap(colours(i),:));
0062       end
0063    else
0064    if size(colours,1)==1 && size(colours,2)==3
0065       % need to work around ^%$#%$# matlab bug which
0066       % forces an incorrect interpretation is colours of this size
0067       hh= patch(Xs(:,[1:3,1]), ...
0068                 Ys(:,[1:3,1]), ...
0069                 Zs(:,[1:3,1]), ...
0070                 colours(:,[1:3,1]), ...
0071             'EdgeColor','none','CDataMapping','direct');
0072    else
0073       hh= patch(Xs,Ys,Zs,colours, ...
0074             'EdgeColor','none','CDataMapping','direct');
0075    end
0076    end
0077 end

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005