diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/affine/carve_it.m | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) | |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
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 | |||
