diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m b/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m new file mode 100755 index 0000000..1a44f89 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m | |||
@@ -0,0 +1,25 @@ | |||
1 | function img = carve_it(I,center,window_size_h) | ||
2 | |||
3 | [size_y,size_x]= size(I); | ||
4 | min_x = round(center(1)-window_size_h(1)); | ||
5 | max_x = round(center(1)+window_size_h(1)); | ||
6 | min_y = round(center(2)-window_size_h(2)); | ||
7 | max_y = round(center(2)+window_size_h(2)); | ||
8 | window_size = window_size_h*2 +1; | ||
9 | |||
10 | if (min_x <1)|(max_x > size_x)|(min_y<1)|(max_y>size_y), | ||
11 | disp('window too big'); | ||
12 | center | ||
13 | window_size_h | ||
14 | img = zeros(window_size(2),window_size(1)); | ||
15 | n_min_x = max(1,round(min_x)); | ||
16 | n_min_y = max(1,round(min_y)); | ||
17 | n_max_x = min(size_x,round(max_x)); | ||
18 | n_max_y = min(size_y,round(max_y)); | ||
19 | img(1+(n_min_y-min_y):window_size(2)-(max_y-n_max_y),1+(n_min_x-min_x):window_size(1)-(max_x-n_max_x))=I(n_min_y:n_max_y,n_min_x:n_max_x); | ||
20 | else | ||
21 | img = I(center(2)-window_size_h(2):center(2)+window_size_h(2),... | ||
22 | center(1)-window_size_h(1):center(1)+window_size_h(1)); | ||
23 | end | ||
24 | |||
25 | |||