|
9 | 9 | relative_path_from_full_tile_index, ...
|
10 | 10 | center_tile_relative_path)
|
11 | 11 |
|
| 12 | + % Extracts a 3x3x3 subset of tiles around a given central tile. |
| 13 | + % Good for running analysis on a small subset of tiles |
| 14 | + % |
| 15 | + % The full_tile_index is the index of a tile in the full tile set. |
| 16 | + % The tile_index is the index of a tile withing the extracted subset. |
| 17 | + % Currently the extracted subset is always a 3x3x3 cuboid of tiles. |
| 18 | + |
| 19 | + % Get the full tile index of the center tile |
12 | 20 | is_center_tile_from_full_tile_index = strcmp(center_tile_relative_path, relative_path_from_full_tile_index) ;
|
13 | 21 | center_tile_full_index = find(is_center_tile_from_full_tile_index) ;
|
14 |
| - center_tile_full_ijk1 = full_tile_ijk1_from_full_tile_index(center_tile_full_index, :) ; %#ok<FNDSB> |
15 |
| - is_in_hood_from_full_tile_ijk1 = false(size(full_tile_index_from_full_tile_ijk1)) ; % "hood" == "neighborhood" b/c I'm *very* street |
16 |
| - is_in_hood_from_full_tile_ijk1(center_tile_full_ijk1(1)-1:center_tile_full_ijk1(1)+1, ... |
17 |
| - center_tile_full_ijk1(2)-1:center_tile_full_ijk1(2)+1, ... |
18 |
| - center_tile_full_ijk1(3)-1:center_tile_full_ijk1(3)+1) = true ; |
19 | 22 |
|
| 23 | + % Get the one-based ijk (integral xyz) coordinates of the center tile |
| 24 | + % within the full tile block |
| 25 | + center_tile_full_ijk1 = full_tile_ijk1_from_full_tile_index(center_tile_full_index, :) ; %#ok<FNDSB> |
20 | 26 |
|
21 |
| - full_tile_index_from_tile_ijk1 = full_tile_index_from_full_tile_ijk1(is_in_hood_from_full_tile_ijk1) ; |
22 |
| - full_tile_index_from_tile_index = full_tile_index_from_tile_ijk1(:) ; |
| 27 | + % Get the 3x3x3 array of file tile indices around the central tile |
| 28 | + full_tile_index_from_tile_ijk1 = ... |
| 29 | + full_tile_index_from_full_tile_ijk1(center_tile_full_ijk1(1)-1:center_tile_full_ijk1(1)+1, ... |
| 30 | + center_tile_full_ijk1(2)-1:center_tile_full_ijk1(2)+1, ... |
| 31 | + center_tile_full_ijk1(3)-1:center_tile_full_ijk1(3)+1) ; |
| 32 | + |
| 33 | + % The raw tile index is the index of each tile within the 3x3x3 block. |
| 34 | + % The actual tile index may differ because some tiles may be missing. |
| 35 | + % Missing tiles in full_tile_index_from_full_tile_ijk1 are represented by |
| 36 | + % nans. |
| 37 | + |
| 38 | + % Get the array that maps from raw tile indices to full tile indices |
| 39 | + full_tile_index_from_raw_tile_index = full_tile_index_from_tile_ijk1(:) ; % may have nans for missing tiles |
| 40 | + |
| 41 | + % Get the mapping from tile indices to raw tile indices |
| 42 | + raw_tile_count = length(full_tile_index_from_raw_tile_index) ; % Should be 27, always |
| 43 | + assert(raw_tile_count==27) ; |
| 44 | + raw_tile_index_from_raw_tile_index = (1:raw_tile_count)' ; |
| 45 | + is_present_from_raw_tile_index = isfinite(full_tile_index_from_raw_tile_index) ; |
| 46 | + raw_tile_index_from_tile_index = raw_tile_index_from_raw_tile_index(is_present_from_raw_tile_index) ; |
| 47 | + assert(all(isfinite(raw_tile_index_from_tile_index))) ; % There shouldn't be any nans in raw_tile_index_from_tile_index |
23 | 48 |
|
24 |
| - full_tile_count = length(relative_path_from_full_tile_index) ; |
25 |
| - tile_index_from_full_tile_index = invert_map_array(full_tile_index_from_tile_index, full_tile_count) ; |
26 |
| - tile_index_from_tile_ijk1 = tile_index_from_full_tile_index(full_tile_index_from_tile_ijk1) ; |
| 49 | + % Get the mapping from tile indices to full tile indices |
| 50 | + full_tile_index_from_tile_index = full_tile_index_from_raw_tile_index(is_present_from_raw_tile_index) ; |
27 | 51 |
|
| 52 | + % Invert raw_tile_index_from_tile_index |
| 53 | + tile_indexoid_from_raw_tile_index = invert_map_array(raw_tile_index_from_tile_index, raw_tile_count) ; |
| 54 | + % tile_indexoid_from_raw_tile_index has zeros for missing raw tile indices, |
| 55 | + % want those to be nan's |
| 56 | + tile_index_from_raw_tile_index = tile_indexoid_from_raw_tile_index ; |
| 57 | + tile_index_from_raw_tile_index(tile_indexoid_from_raw_tile_index==0) = nan ; |
28 | 58 |
|
| 59 | + % Get mapping from tile_ijk1 to the tile index |
| 60 | + raw_tile_index_from_tile_ijk1 = reshape(raw_tile_index_from_raw_tile_index, [3 3 3]) ; |
| 61 | + tile_index_from_tile_ijk1 = tile_index_from_raw_tile_index(raw_tile_index_from_tile_ijk1) ; |
| 62 | + |
| 63 | + % Get the mapping from tile index to tile ijk1 (within the subset) |
29 | 64 | full_tile_ijk1_from_tile_index = full_tile_ijk1_from_full_tile_index(full_tile_index_from_tile_index, :) ;
|
30 | 65 | offset_ijk = min(full_tile_ijk1_from_tile_index, [] , 1) ;
|
31 | 66 | tile_ijk1_from_tile_index = full_tile_ijk1_from_tile_index - offset_ijk + 1 ;
|
32 |
| - |
| 67 | + |
| 68 | + % Get the xyz coordinate of each tile in the subset |
33 | 69 | xyz_from_tile_index = xyz_from_full_tile_index(full_tile_index_from_tile_index,:) ;
|
| 70 | + |
| 71 | + % Get the relative path of each tile in the subset |
34 | 72 | relative_path_from_tile_index = relative_path_from_full_tile_index(full_tile_index_from_tile_index) ;
|
35 | 73 | end
|
0 commit comments