source: an2_rot3d.m @ 41

Last change on this file since 41 was 39, checked in by tjniskan, 11 years ago
  • Added "Recent Files" quick access menu in File-menu
  • Fixed a bug in plugins/copy_data_to_workspace.m that made writing a

new name for a variable difficult

  • Fixed a bug in the file prefix editbox in an2_export_gui.m
  • Changed references to Analyze 2.0 in all license notices to Aedes.

The name change should now be complete...

M an2_export_gui.m
M an2_cellsprintf.m
M an2_calc_wait.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_update.m
M an2_write_nifti.m

File size: 2.1 KB
Line 
1function B = an2_rot3d(A,k,dim)
2% AN2_ROT3D - Rotate 3D matrix in 90 degree steps in 3 dimensions
3%
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% This function is a part of Aedes - A graphical tool for analyzing
15% medical images
16%
17% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
18%
19% Department of Physics, (or Department of Neurobiology)
20% University of Kuopio, FINLAND
21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
30
31if nargin<2
32  error('AN2_ROT3D: Too few input arguments!')
33elseif nargin<3
34  dim = 3; % Use dim 3 as a default
35end
36
37if ndims(A)~=3 || ~isnumeric(A)
38  error('First input argument must be a numerical 3D-matrix!')
39end
40
41if ~isnumeric(k) || ~any(k==[0 1 2 3 4])
42  error('The second input argument has to be a scalar 0,1,2,3, or 4!')
43end
44
45switch dim
46  case 1
47    if k==1 % Rotate 90 degrees along dim 1
48      B = flipdim(permute(A,[1 3 2]),3);
49    elseif k==2 % Rotate 180 degrees along dim 1
50      B = flipdim(flipdim(A,3),2);
51    elseif k==3 % Rotate 270 degrees along dim 1
52      B = flipdim(permute(A,[1 3 2]),2);
53    elseif k==0 || k==4
54      B=A;
55    end
56  case 2
57    if k==1 % Rotate 90 degrees along dim 2
58      B = flipdim(permute(A,[3 2 1]),3);
59    elseif k==2 % Rotate 180 degrees along dim 2
60      B = flipdim(flipdim(A,3),1);
61    elseif k==3 % Rotate 270 degrees along dim 2
62      B = flipdim(permute(A,[3 2 1]),1);
63    elseif k==0 || k==4
64      B=A;
65    end
66  case 3
67    if k==1 % Rotate 90 degrees along dim 3
68      B = flipdim(permute(A,[2 1 3]),1);
69    elseif k==2 % Rotate 180 degrees along dim 3
70      B = flipdim(flipdim(A,2),1);
71    elseif k==3 % Rotate 270 degrees along dim 3
72      B = flipdim(permute(A,[2 1 3]),2);
73    elseif k==0 || k==4
74      B=A;
75    end
76  otherwise
77    return
78end
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008