# HG changeset patch # User magedrifaat # Date 1662299867 -7200 # Node ID bbb41a5f377a300efe0d86c33cc6fbc00e22f7f7 # Parent 1a564892fef1830b9d0f3d10c37b50b5e7022822 __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. diff -r 1a564892fef1 -r bbb41a5f377a scripts/image/private/__tiff_imread__.m --- 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