0001 function [colours,scl_data]= calc_colours(img, set_value, do_colourbar)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 if nargin==0; error('calc_colours: expecting argument'); end
0117 if ischar(img) && strcmp(img,'UNIT_TEST'); do_unit_test; return; end
0118
0119 if ischar(img)
0120
0121 if nargin==1;
0122 if strcmp(img,'defaults')
0123 set_colours_defaults; return
0124 end
0125 colours= get_field(img);
0126 else
0127 colours= set_field(img, set_value);
0128 end
0129 return;
0130
0131 elseif isfield(img,'type')
0132 img_data= get_img_data( img );
0133 pp=get_colours(img(1)) ;
0134 else
0135 img_data= img;
0136
0137 if nargin==1
0138 pp=get_colours( [] );
0139 else
0140 pp=get_colours(set_value);
0141 end
0142 end
0143
0144
0145 if nargin < 3; do_colourbar = 0; end
0146 ref_lev = 'use_global';
0147
0148
0149 if isempty(img_data)
0150 colours = 'k';
0151 return;
0152 end
0153
0154 m= size(img_data,1); n=size(img_data,2);
0155
0156
0157
0158 [scl_data, ref_lev, max_scale] = scale_for_display( img_data(:), pp);
0159
0160 backgnd= isnan(scl_data);
0161 scl_data(backgnd)= mean( scl_data(~backgnd));
0162
0163 if pp.mapped_colour
0164 colours=set_mapped_colour(pp, backgnd, scl_data);
0165 colours= reshape( colours, m,n,[]);
0166 else
0167 [red,grn,blu] = blu_red_axis( pp, scl_data, backgnd );
0168 colours= reshape( [red,grn,blu],m,n,3);
0169 end
0170
0171
0172 if do_colourbar
0173 if ~pp.mapped_colour
0174 warning('Colorbar not available without mapped_colour option');
0175 elseif do_colourbar < 0
0176 eidors_colourbar(-do_colourbar,max_scale,pp.cb_shrink_move,1)
0177 else
0178 eidors_colourbar(max_scale,ref_lev,pp.cb_shrink_move)
0179 end
0180 end
0181
0182
0183 function set_colours_defaults;
0184 clear -global eidors_colours;
0185
0186 calc_colours('greylev',-.001);
0187 calc_colours('sat_adj',.9);
0188 calc_colours('window_range', .7);
0189 calc_colours('backgnd',[.35,.45,.40]);
0190 calc_colours('mapped_colour',127);
0191 calc_colours('ref_level','auto');
0192 calc_colours('npoints',64);
0193 calc_colours('clim',[]);
0194 calc_colours('cb_shrink_move',[1,1,0]);
0195 calc_colours('transparency_thresh',0.25);
0196 eidors_msg('Setting Default Colours',2);
0197 calc_colours('cmap_type','blue_red');
0198
0199
0200
0201 function [red,grn,blu] = blu_red_axis( pp, scale_data, backgnd )
0202 if ~isfield(pp,'cmap_type')
0203 pp.cmap_type = 'blue_red';
0204 end;
0205
0206
0207
0208 W= pp.window_range; K= 3*W/(1+2*W);
0209 scale_data= sign(scale_data) .* ( ...
0210 ( K/W* abs(scale_data) ) .* (abs(scale_data)<=W) + ...
0211 (K+K/W/3*(abs(scale_data)-W)) .* (abs(scale_data)> W) );
0212
0213 if isnumeric(pp.cmap_type)
0214 user_colourmap = pp.cmap_type;
0215 pp.cmap_type= 'user_colourmap';
0216 end
0217
0218 switch pp.cmap_type
0219 case 'user_colourmap'
0220 red = user_colourmap(:,1);
0221 grn = user_colourmap(:,2);
0222 blu = user_colourmap(:,3);
0223 case 'blue_red'
0224 [red,grn,blu]= blue_red_colours(pp,scale_data);
0225 case {'draeger', 'draeger-difference'}
0226 [red,grn,blu]= draeger_colours(pp,scale_data, 'difference2014');
0227 case 'draeger-2009',
0228 [red,grn,blu]= draeger_colours(pp,scale_data, '2009');
0229 case 'draeger-tidal',
0230 [red,grn,blu]= draeger_colours(pp,scale_data, 'tidal2014');
0231 case 'swisstom'
0232 [red,grn,blu]= swisstom_colours(pp,scale_data);
0233 case 'timpel'
0234 [red,grn,blu]= timpel_colours(pp,scale_data);
0235 case 'jet'
0236 [red,grn,blu]= jet_colours(pp,scale_data);
0237 case 'jetair'
0238
0239 scd = (scale_data + 0.5)/0.6;
0240 [red,grn,blu]= jet_colours(pp,scd);
0241 case 'blue_yellow'
0242 [red,grn,blu] = blue_yellow_colours(pp,scale_data);
0243 case 'greyscale'
0244 [red,grn,blu] = greyscale_colours(pp,scale_data);
0245 case 'greyscale-inverse'
0246 [red,grn,blu] = greyscale_colours(pp,-scale_data);
0247 case 'copper'
0248 [red,grn,blu] = copper_colours(pp,scale_data);
0249 case 'blue_white_red'
0250 [red,grn,blu]= blue_white_red_colours(pp,scale_data);
0251 case 'black_red'
0252 [red,grn,blu] = black_red_colours(pp,scale_data);
0253 case 'blue_black_red'
0254 [red,grn,blu] = blue_black_red_colours(pp,scale_data);
0255 case 'polar_colours'
0256 [red,grn,blu] = polar_blue_white_red_colours(pp,scale_data);
0257 case 'flame'
0258 [red,grn,blu] = flame_colours(pp,scale_data);
0259 case 'ice'
0260 [red,grn,blu] = ice_colours(pp,scale_data);
0261
0262 otherwise
0263 error(['specified cmap_type not understood:',pp.cmap_type]);
0264 end
0265
0266 red(red>1) = 1;
0267 grn(grn>1) = 1;
0268 blu(blu>1) = 1;
0269
0270
0271 red(backgnd) = pp.backgnd(1);
0272 grn(backgnd) = pp.backgnd(2);
0273 blu(backgnd) = pp.backgnd(3);
0274
0275
0276 if isfield(pp,'image_field')
0277 red(2)=pp.image_field(1);
0278 grn(2)=pp.image_field(2);
0279 blu(2)=pp.image_field(3);
0280 end
0281
0282
0283 function [red,grn,blu]= blue_red_colours(pp,scale_data);
0284 if 0
0285 D= sign(pp.greylev+eps);
0286 glev= abs(pp.greylev);
0287 F= 3*pp.sat_adj;
0288
0289 red= D*F*abs(scale_data+D/F) - D + (D==-1);
0290 red= red.*(red>0).*(red<1) + (red>=1);
0291 red= red*(1-glev) + glev;
0292 end
0293 ofs= (pp.greylev >= 0);
0294 glev= abs(pp.greylev);
0295
0296 D= (2*ofs - 1);
0297 ofs= ofs - 2*(ofs==0);
0298 F= 3*pp.sat_adj;
0299 DF= D*F; D_F= D/F;
0300
0301 red= DF*abs(scale_data+D_F) - ofs;
0302 red= red.*(red>0).*(red<1) + (red>=1);
0303
0304 grn= DF*abs(scale_data ) - ofs;
0305 grn= grn.*(grn>0).*(grn<1) + (grn>=1);
0306
0307 blu= DF*abs(scale_data-D_F) - ofs;
0308 blu= blu.*(blu>0).*(blu<1) + (blu>=1);
0309
0310 if pp.greylev >=0
0311 red= red*(1-glev) + glev;
0312 grn= grn*(1-glev) + glev;
0313 blu= blu*(1-glev) + glev;
0314 else
0315 red= red*(1-glev);
0316 grn= grn*(1-glev);
0317 blu= blu*(1-glev);
0318 end
0319
0320 function [red,grn,blu]= swisstom_colours(pp,scale_data);
0321 backgnd = hex2dec(['59';'59';'59']);
0322 alphapts = [-255,32,160,255]/255;
0323 alphaval = [0, 0, 1, 1];
0324 alp = interp1(alphapts, alphaval, -scale_data, 'linear');
0325
0326 hexcolours = ['3E4A50';
0327 '2F4D58';
0328 '357892';
0329 '2AB1DF';
0330 '61D1FB';
0331 'CFF0FE'];
0332 redpts = hex2dec(hexcolours(:,1:2));
0333 grnpts = hex2dec(hexcolours(:,3:4));
0334 blupts = hex2dec(hexcolours(:,5:6));
0335 interppts = linspace(0,1, size(hexcolours,1));
0336
0337 redpts = redpts([1,1:end]);
0338 grnpts = grnpts([1,1:end]);
0339 blupts = blupts([1,1:end]);
0340 interppts = [-1,interppts];
0341
0342 red = interp1(interppts, redpts,-scale_data, 'linear');
0343 grn = interp1(interppts, grnpts,-scale_data, 'linear');
0344 blu = interp1(interppts, blupts,-scale_data, 'linear');
0345
0346 red = red.*alp + backgnd(1)*(1-alp);
0347 grn = grn.*alp + backgnd(2)*(1-alp);
0348 blu = blu.*alp + backgnd(3)*(1-alp);
0349
0350 red = red/255;
0351 grn = grn/255;
0352 blu = blu/255;
0353
0354 function [red,grn,blu]= timpel_colours(pp,scale_data)
0355 sd = -scale_data*100;
0356 P00 = (sd< 9);
0357 p09 = (sd>= 9) .* (sd<10) .* (sd- 9) / (10- 9); P09 = p09 >0;
0358 p10 = (sd>=10) .* (sd<17) .* (sd-10) / (17-10); P10 = p10 >0;
0359 p17 = (sd>=17) .* (sd<30) .* (sd-17) / (30-17); P17 = p17 >0;
0360 p30 = (sd>=30) .* (sd<60) .* (sd-30) / (60-30); P30 = p30 >0;
0361 p60 = (sd>=60) .* (sd<85) .* (sd-60) / (85-60); P60 = p60 >0;
0362 p85 = (sd>=85) .* (sd-85) /(100-85); P85 = p85 >0;
0363
0364
0365 red = 150*P00 + 198*p85;
0366 grn = 150*P00 + 88 *P09 + ...
0367 88*P10 + (99- 88)*p10 + ...
0368 99*P17 + (121- 99)*p17 + ...
0369 121*P30 + (190-121)*p30 + ...
0370 190*P60 + (243-190)*p60 + ...
0371 243*P85 + (251-243)*p85;
0372 blu = 150*P00 + 159 *P09 + ...
0373 180*P10 + (180-159)*p10 + ...
0374 255*P17 + ...
0375 255*P30 + ...
0376 255*P60 + ...
0377 255*P85 ;
0378
0379 red = red/255;
0380 grn = grn/255;
0381 blu = blu/255;
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398 function [red,grn,blu] = draeger_colours(pp,scale_data, version);
0399 switch version
0400 case '2009'
0401 grn= (-scale_data>0.2) .* (-scale_data - 0.2)/0.8;
0402 red=grn + ( scale_data>0.2) .* ( scale_data - 0.2)/0.8*2/3;
0403
0404 blu= (-scale_data>0.1) .* (-scale_data - 0.1)/0.1;
0405 blu(-scale_data>0.2) = 1;
0406 blu=blu + ( scale_data>0.2) .* ( scale_data - 0.2)/0.8*2/3;
0407 case 'tidal2014'
0408 sd = -scale_data*100;
0409 p20 = (sd> 20) .* (sd<= 100) .* (sd - 20) / (100-20);
0410 P20 = (p20>0);
0411 p10 = (sd> 10) .* (sd<= 20) .* (sd - 10) / ( 20-10);
0412 n20 = (sd<-20) .* (sd>=-100) .* (sd + 20) /-(100-20);
0413 red = 255*p20 + 170*n20;
0414 grn = 255*p20;
0415 blu = 255*P20 + 255*p10 + 170*n20;
0416
0417 red = red/255;
0418 grn = grn/255;
0419 blu = blu/255;
0420
0421 case 'difference2014';
0422 sd = -scale_data*100;
0423 p40 = (sd> 40) .* (sd<= 100) .* (sd - 40) / (100-40);
0424 P40 = (p40>0);
0425 p10 = (sd> 10) .* (sd<= 40) .* (sd - 10) / ( 40-10);
0426 n10 = (sd<-10) .* (sd>=- 40) .* (sd + 10) /-( 40-10);
0427 n40 = (sd<-40) .* (sd>=-100) .* (sd + 40) /-(100-40);
0428 N40 = (n40>0);
0429 red = 132*p40 + 255*n10 + 255*N40;
0430 grn = 153*p10 + 153*P40 + (240-153)*P40 + ...
0431 153*n10 + 153*N40 + (240-153)*n40;
0432 blu = 153*n40 + 255*p10 + 255*P40;
0433
0434 red = red/255;
0435 grn = grn/255;
0436 blu = blu/255;
0437 otherwise; error('version "%s" not recognized', version);
0438 end
0439
0440
0441 function [red,grn,blu] = jet_colours(pp,scale_data);
0442 grn = 2*(3/4 - abs(scale_data));
0443 grn(grn>1) = 1; grn(grn<0) = 0;
0444
0445 red = 1.5 - 2*abs(scale_data + 0.5);
0446 red(red>1) = 1; red(red<0) = 0;
0447
0448 blu = 1.5 - 2*abs(scale_data - 0.5);
0449 blu(blu>1) = 1; blu(blu<0) = 0;
0450
0451
0452 function [red,grn,blu] = blue_yellow_colours(pp,scale_data);
0453
0454
0455
0456 clrs = flipud([0.75 1 1; 0 1 1; 0 0 1;...
0457 0 0 0; 1 0 0; 1 1 0; 1 1 0.75]);
0458
0459 y = linspace(-1,1,size(clrs,1));
0460 cc = interp2(1:3,y,clrs,1:3,scale_data);
0461 red = cc(:,1);
0462 grn = cc(:,2);
0463 blu = cc(:,3);
0464
0465
0466
0467 function [red,grn,blu]= greyscale_colours(pp,scale_data);
0468 cc= 0.5 - scale_data/2;
0469 red = cc;
0470 grn = cc;
0471 blu = cc;
0472
0473
0474
0475
0476 function [red,grn,blu]= copper_colours(pp,scale_data);
0477
0478 cc= 0.5 + scale_data/2;
0479 red = min(cc * 1.2500,1);
0480 grn = cc * 0.7812;
0481 blu = cc * 0.4975;
0482
0483 function [red,grn,blu]= blue_white_red_colours(pp,scale_data);
0484
0485
0486 clrs = flipud([0 0 1; 1 1 1; 1 0 0]);
0487
0488 y = linspace(-1,1,size(clrs,1));
0489 cc = interp2(1:3,y,clrs,1:3,scale_data);
0490 red = cc(:,1);
0491 grn = cc(:,2);
0492 blu = cc(:,3);
0493
0494
0495
0496 function [red,grn,blu] = black_red_colours(pp,scale_data);
0497 red = 0.5 + scale_data/2;
0498 blu = 0*scale_data;
0499 grn = blu;
0500
0501 function [red,grn,blu] = flame_colours(pp,scale_data);
0502 sd = 0.5 + scale_data/2;
0503 red = sd*0+1;
0504 blu = (1 - 3*sd);
0505 grn = (1 - 3*sd);
0506 grn(grn<0) = -2*grn(grn<0);
0507 t=0.8;
0508 grn(sd>t) = 1-(sd(sd>t)-t)/(1-t);
0509 red(sd>t) = 1-(sd(sd>t)-t)/(1-t);
0510 blu(sd>t) = (sd(sd>t)-t)/(1-t);
0511 [red,grn,blu] = saturate(red,grn,blu);
0512
0513 function [red,grn,blu] = ice_colours(pp,scale_data);
0514 sd = 0.5 + scale_data/2;
0515 blu = (1 - 2*sd);
0516 grn = (1 - 3*sd);
0517 red = (1 - 2*sd);
0518 red(red<0) = -2*red(red<0);
0519 t=0.5;
0520
0521
0522 grn(sd>t) = (2*sd(sd>t)-1);
0523 [red,grn,blu] = saturate(red,grn,blu);
0524
0525 function [red,grn,blu] = saturate(red,grn,blu);
0526 red(red>1)=1;
0527 grn(grn>1)=1;
0528 blu(blu>1)=1;
0529 red(red<0)=0;
0530 grn(grn<0)=0;
0531 blu(blu<0)=0;
0532
0533
0534 function [red,grn,blu] = blue_black_red_colours(pp,scale_data);
0535 red =-min(0,scale_data);
0536 blu = max(0,scale_data);
0537 grn = 0*scale_data;
0538
0539
0540
0541
0542 function [red,grn,blu] = polar_blue_white_red_colours(pp,scale_data);
0543
0544
0545
0546
0547
0548 red = min(1, 1 + scale_data);
0549 grn = 1 - abs(scale_data);
0550 blu = min(1, 1 - scale_data);
0551
0552
0553 function pp=get_colours( img );
0554 global eidors_colours;
0555 pp= eidors_colours;
0556
0557 pp.component = 'real';
0558
0559
0560 try
0561
0562 fds= fieldnames(img(1).calc_colours);
0563 for fdn= fds(:)';
0564 fdn= fdn{1};
0565 pp.( fdn ) = img(1).calc_colours.(fdn);
0566 end
0567 end
0568 if isfield(img, 'eidors_colourbar')
0569 pp.cb_shrink_move = [1,1,0];
0570 try
0571 pp.cb_shrink_move = img.eidors_colourbar.cb_shrink_move;
0572 end
0573 end
0574
0575 function BGI= backgndidx;
0576 BGI= 1;
0577
0578 function colours=set_mapped_colour(pp, backgnd, img_data)
0579
0580
0581
0582
0583
0584 ncol= pp.mapped_colour;
0585 [red,grn,blu] = blu_red_axis( pp, ...
0586 [-1,linspace(-1,1,2*ncol - 1)]', backgndidx );
0587 colormap([red,grn,blu]);
0588
0589
0590 if isfield(pp,'image_field')
0591 warning(['calc_colours: image_field is an experimental feature ' ...
0592 'and will be re-implemented']);
0593 infmask = isinf(img_data);
0594 mindata = min(img_data(~infmask));
0595 colours = fix( (img_data-mindata) * (ncol-1))' + 3;
0596 colours(backgnd)= backgndidx;
0597 colours(pp.image_field_idx)=2;
0598 return
0599 end
0600
0601
0602
0603
0604 colours = img_data'; colours = colours * (ncol-1);
0605 colours = fix ( colours ); colours = colours + ncol + 1;
0606 colours(backgnd)= backgndidx;
0607
0608 function value= get_field(param);
0609 global eidors_colours;
0610 if strcmp(param,'colourmap')
0611 ncol= eidors_colours.mapped_colour;
0612 [red,grn,blu] = blu_red_axis( eidors_colours, ...
0613 [-1,linspace(-1,1,2*ncol - 1)]', backgndidx );
0614 value= [red,grn,blu];
0615 else
0616 value = getfield(eidors_colours, param);
0617 end
0618
0619 function value= set_field(param, value);
0620 global eidors_colours;
0621 eidors_colours = setfield(eidors_colours, param, value);
0622 value= eidors_colours;
0623
0624
0625 function do_unit_test
0626 calc_colours('defaults');
0627
0628 img = eidors_obj('image','test');
0629
0630 img.calc_colours.mapped_colour = 127;
0631 img.calc_colours.ref_level = 'auto';
0632 img.calc_colours.sat_adj = 0.9;
0633 img.calc_colours.window_range = 0.9;
0634 img.calc_colours.greylev = -0.01;
0635
0636 img.elem_data = [-2;0;0;0;1;3];
0637 unit_test_cmp('cc01a', calc_colours(img), [44; 128; 128; 128; 170; 254]);
0638
0639 imgk(1) = img; imgk(2) = img;
0640 unit_test_cmp('cc01b', calc_colours(imgk), [44; 128; 128; 128; 170; 254]*[1,1]);
0641 img.calc_colours.ref_level = 0;
0642 unit_test_cmp('cc01c', calc_colours(img), [44; 128; 128; 128; 170; 254]);
0643
0644 img.calc_colours.ref_level = 1;
0645 unit_test_cmp('cc02', calc_colours(img), [ 2; 86; 86; 86; 128; 212]);
0646
0647 img.calc_colours.greylev = -.1;
0648 img.calc_colours.mapped_colour = 0;
0649 img.elem_data = [-2;1;3];
0650 cm= reshape([ 0, 0.9, 0.9; 0, 0.9, 0.0643; 0.27, 0.9, 0]',[3,1,3]);
0651 unit_test_cmp('cc03', calc_colours(img), cm,1e-3)
0652
0653 img.calc_colours.greylev = .1;
0654 cm= reshape([ 0.73, 1.0, 1.0; 0.1, 0.1, 0.1; 1.0, 0.9357, 0.1],[3,1,3]);
0655 unit_test_cmp('cc04', calc_colours(img), cm,1e-3)
0656
0657 calc_colours('greylev',0);
0658 calc_colours('sat_adj',1);
0659 calc_colours('mapped_colour',4);
0660 calc_colours('backgnd',[0.5,0.5,0.5]);
0661 cc= calc_colours('colourmap');
0662 unit_test_cmp('cc05',cc, ...
0663 [2,2,2;4,4,4;2,4,4;0,1,4;0,0,0;4,1,0;4,4,2;4,4,4]/4,1e-10);
0664
0665 calc_colours('greylev',-.01);
0666 cc= calc_colours('colourmap');
0667 unit_test_cmp('cc06',cc, [200,200,200;0,0,0;0,0,198; ...
0668 0,297,396;396,396,396;396,297,0;198,0,0;0,0,0]/400,1e-10);
0669
0670 calc_colours('greylev',0);
0671 calc_colours('sat_adj',.5);
0672 cc= calc_colours('colourmap');
0673 unit_test_cmp('sa01',cc(2,:), [0,5,10]/10,1e-10);
0674
0675 calc_colours('sat_adj',.8);
0676 cc= calc_colours('colourmap');
0677 unit_test_cmp('sa02',cc(2,:), [4,10,10]/10,1e-10);
0678
0679 calc_colours('sat_adj',1 );
0680 cc= calc_colours('colourmap');
0681 unit_test_cmp('sa03',cc(2,:), [10,10,10]/10,1e-10);
0682
0683
0684 unit_test_cmp('bg01',cc(1,:), [50,50,50]/100, 1e-10);
0685 calc_colours('defaults');
0686 cc= calc_colours('colourmap');
0687
0688
0689
0690
0691 unit_test_cmp('bg02',cc(1,:), [35,50,55]/100, 1e-10);
0692
0693 unit_test_cmp('mc01',size(cc), [127*2,3]);
0694 calc_colours('mapped_colour',4);
0695 cc= calc_colours('colourmap');
0696 unit_test_cmp('mc02',size(cc), [4*2,3]);
0697
0698
0699
0700
0701 test.blue_red = [0,0,2997; 9990,9990,9990; 2997,0,0]/1e4;
0702
0703 test.draeger = [5176,9412,10000;0,0,0;10000,9412,6000]/1e4;
0704 test.timpel = [7765,9843,10000;5882,5882,5882;5882,5882,5882]/1e4;
0705 test.jet = [5000,0,0;5000,10000,5000;0,0,5000]/1e4;
0706 test.jetair = [8333,0,0; 0,0,8333;0,0,0]/1e4;
0707 test.blue_yellow = [10000,10000,7500; 0,0,0;7500,10000,10000]/1e4;
0708 test.greyscale = flipud([0,0,0;5000,5000,5000;10000,10000,10000])/1e4;
0709 test.copper = [0,0,0;6250,3906,2487;10000,7812,4975]/1e4;
0710 test.blue_white_red = [10000,0,0;10000,10000,10000;0,0,10000]/1e4;
0711 test.black_red = [0,0,0;5000,0,0;10000,0,0]/1e4;
0712 test.blue_black_red = [10000,0,0;0,0,0;0,0,10000]/1e4;
0713 test.polar_colours = [0,0,10000;10000,10000,10000;10000,0,0]/1e4;
0714 test.flame = [10000,10000,10000;10000,10000,0;0,0,10000]/1e4;
0715 test.ice = [10000,10000,10000;0,0,0;10000,10000,0]/1e4;
0716
0717 calc_colours('defaults');
0718 calc_colours('mapped_colour',4);
0719 for ct = fieldnames(test)'
0720 ct = ct{1};
0721 tname = sprintf('ctm4(%s)',ct);
0722 calc_colours('cmap_type', ct);
0723 cc= calc_colours('colourmap');
0724 unit_test_cmp(tname,cc([2,5,8],:), test.( ct ), 1e-4);
0725 end
0726
0727 calc_colours('defaults');
0728 calc_colours('mapped_colour',0);
0729 for ct = fieldnames(test)'
0730 ct = ct{1};
0731 tname = sprintf('ctm0(%s)',ct);
0732 calc_colours('cmap_type', ct);
0733
0734 cc= calc_colours(linspace(-1,1,7)); cc= squeeze(cc);
0735 unit_test_cmp(tname,cc([1,4,7],:), test.( ct ), 1e-4);
0736 end
0737
0738 calc_colours('defaults');