AVW_FLIP - ortho-flip Analyze data image (avw.img) [ avw ] = avw_flip(avw,dims) where avw is the data struct returned from avw_img_read and dims is a cell array of strings, eg: dims = {'x','y','z'} with any number of cells, in any order. For each cell of dims, the dimension of avw.img is flipped, independently of all other dimensions and the order in which they are specified. There are no 3D rotations, which are not orthogonal flips. This function will most likely invalidate the .img orientation, so use of it is not recommended. There is no attempt in this function to maintain the validity of the avw.hdr.hist.orient field. In fact, this will be set to an invalid value (9). see also AVW_IMG_READ, AVW_VIEW
0001 function [ avw ] = avw_flip(avw,dims) 0002 0003 % AVW_FLIP - ortho-flip Analyze data image (avw.img) 0004 % 0005 % [ avw ] = avw_flip(avw,dims) 0006 % 0007 % where avw is the data struct returned from avw_img_read 0008 % and dims is a cell array of strings, eg: dims = {'x','y','z'} 0009 % with any number of cells, in any order. 0010 % 0011 % For each cell of dims, the dimension of avw.img is flipped, 0012 % independently of all other dimensions and the order in which 0013 % they are specified. There are no 3D rotations, which are 0014 % not orthogonal flips. 0015 % 0016 % This function will most likely invalidate the .img orientation, 0017 % so use of it is not recommended. There is no attempt in this 0018 % function to maintain the validity of the avw.hdr.hist.orient 0019 % field. In fact, this will be set to an invalid value (9). 0020 % 0021 % see also AVW_IMG_READ, AVW_VIEW 0022 % 0023 0024 0025 % $Revision: 1332 $ $Date:: 2011-02-24 15:57:20 +0900#$ 0026 0027 % Licence: GNU GPL, no express or implied warranties 0028 % History: 01/2003, Darren.Weber@flinders.edu.au 0029 % 0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0031 0032 version = '[$Revision: 1332 $]'; 0033 fprintf('\nAVW_FLIP [v%s]\n',version(12:16)); 0034 0035 fprintf('...warning, this function can invalidate the .img orientation,\n'); 0036 fprintf('...setting avw.hdr.hist.orient to invalid value = 9.\n'); 0037 avw.hdr.hist.orient = uint8(9); 0038 0039 for i = 1:length(dims), 0040 dim = lower(dims{i}); 0041 switch dim, 0042 case 'x', 0043 fprintf('...flipping X\n'); 0044 xdim = size(avw.img,1); 0045 avw.img = avw.img(xdim:-1:1,:,:); 0046 case 'y', 0047 fprintf('...flipping Y\n'); 0048 ydim = size(avw.img,2); 0049 avw.img = avw.img(:,ydim:-1:1,:); 0050 case 'z', 0051 fprintf('...flipping Z\n'); 0052 zdim = size(avw.img,3); 0053 avw.img = avw.img(:,:,zdim:-1:1); 0054 end 0055 end 0056 0057 return