1 ## Copyright (C) 2012 P. Cloetens
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ## function imcut = cut(im, nn, mn[, cnn, cmn])
19 ## cuts a sub-matrix out of a larger matrix
20 ## cuts in the center of the original matrix, except if new center is specified
21 ## NO CHECKING of validity indices sub-matrix!
24 ## argument 1: original matrix im
25 ## argument 2: number of rows in result
26 ## argument 3: number of columns in result
27 ## argument 4: center row around which to cut ( default: center )
28 ## argument 5: center column around which to cut ( default: center )
31 ## im_roi = cut(im, 1024, 1024) -> cut center 1024x1024 pixels
32 ## im_roi = cut(im, 1024, 1024, 600.5, 700.5) -> cut 1024x1024 pixels around pixels (600-601, 700-701)
34 ## Author: P. Cloetens <cloetens@esrf.eu>
36 ## 2012-10-14 P. Cloetens <cloetens@esrf.eu>
39 function imcut = cut(im, nn, mn, cnn, cmn)
40 if !exist('cnn', 'var')
43 if !exist('cmn', 'var')
55 rb = round(0.5+cnn-nn/2);
57 cb = round(0.5+cmn-mn/2);
59 imcut = im(rb:re, cb:ce);