Mercurial > octave-libtiff
changeset 31209:bbb41a5f377a
__tiff_imread__: improved performance of read_tiled_data
* scripts/image/privat/__tiff_imread__.m (read_tiled_data): added logic to skip
over tiles that are not needed so they aren't unnecessarily read from disk.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Sun, 04 Sep 2022 15:57:47 +0200 |
parents | 1a564892fef1 |
children | e83a62df599b |
files | scripts/image/private/__tiff_imread__.m |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/image/private/__tiff_imread__.m Sun Sep 04 15:30:27 2022 +0200 +++ b/scripts/image/private/__tiff_imread__.m Sun Sep 04 15:57:47 2022 +0200 @@ -202,11 +202,13 @@ ## Calculate the indices of the same columns in the output array data_cols = idivide (cols_in_tile - cols (1), col_stride, "fix") + 1; - tile = img.readEncodedTile (tile_idx); + ## Skip over tiles that are not needed + if (numel (rows_in_tile) != 0 || numel (cols_in_tile) != 0) + tile = img.readEncodedTile (tile_idx); + ## Copy the needed data from the tile array to the output array + data (data_rows, data_cols, :) = tile (tile_rows, tile_cols, :); + endif tile_idx += 1; - - ## Copy the needed data from the tile array to the output array - data (data_rows, data_cols, :) = tile (tile_rows, tile_cols, :); endfor endfor else @@ -234,11 +236,13 @@ ## Calculate the indices of the same columns in the output array data_cols = idivide (cols_in_tile - cols (1), col_stride, "fix") + 1; - tile = img.readEncodedTile (tile_idx); + ## Skip over tiles that are not needed + if (numel (rows_in_tile) != 0 || numel (cols_in_tile) != 0) + tile = img.readEncodedTile (tile_idx); + ## Copy the needed data from the tile array to the output array + data (data_rows, data_cols, ch) = tile (tile_rows, tile_cols); + endif tile_idx += 1; - - ## Copy the needed data from the tile array to the output array - data (data_rows, data_cols, ch) = tile (tile_rows, tile_cols); endfor endfor endfor