changeset 31191:8ada1e68d961

__tiff__.cc (F__tiff_imread__): added support for PixelRegion option.
author magedrifaat <magedrifaat@gmail.com>
date Fri, 26 Aug 2022 23:30:55 +0200
parents a91f2f79e58c
children 6a2bb6f4e41e
files libinterp/corefcn/__tiff__.cc
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/__tiff__.cc	Fri Aug 26 19:03:43 2022 +0200
+++ b/libinterp/corefcn/__tiff__.cc	Fri Aug 26 23:30:55 2022 +0200
@@ -3695,6 +3695,20 @@
         error ("Unsupported sample format");
       }
     
+    // Use octave_value methods to slice the data without knowledge of
+    // the underlying data type to avoid code duplication
+    // FIXME: this approach is slow when the needed region is much smaller
+    // than the image size because the entire image will be read first
+    octave_value_list idx (3);
+    // Need to use range because normal idx_vector constuctor handles steps
+    // in a wrong way (FIXME?)
+    idx(0) = idx_vector (range<double> (row_region (0), row_region (1),
+                                        row_region(2)));
+    idx(1) = idx_vector (range<double> (col_region (0), col_region (1),
+                                        col_region(2)));
+    idx(2) = idx_vector (':');
+    retval(0) = retval(0).index_op (idx);
+    
     if (nargout > 1)
       {
         // Also return the color map if available