changeset 20658:eafc22e4c857

ntsc2rgb: truncate/scale for all types and performance fixes (patch #8709) * scripts/image/ntsc2rgb.m: Matlab only accepts input of class double so on cset 175aed5acb85 it only performed scaling for class double and doing nothing otherwise. However, this can cause issues for the user since it then it will need to be constantly aware of the class (the whole point of accepting any class is not having to worry about it). In addition, make use of automatic broadcasting (instead of multiplying by ones to expand), and drop use of find() since it's faster to use the bool array for indexing than the extra call to find().
author Carnë Draug <carandraug@octave.org>
date Sun, 25 Oct 2015 20:44:13 +0000
parents bc51aa0d604a
children 63f975ff1f7c
files scripts/image/ntsc2rgb.m
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/image/ntsc2rgb.m	Sun Oct 25 19:34:56 2015 +0000
+++ b/scripts/image/ntsc2rgb.m	Sun Oct 25 20:44:13 2015 +0000
@@ -59,13 +59,9 @@
   rgb = yiq * trans;
 
   ## truncating / scaling of double rgb values for Matlab compatibility
-  ## (Other input types are not supported by Matlab. We deal with
-  ## them anyways, but do not truncate or scale those.)
-  if (cls == "double")
-    rgb = max (0,rgb);
-    idx = find (any (rgb'>1));
-    rgb(idx,:) = rgb(idx,:) ./ (max (rgb(idx,:), [], 2) * ones (1,3));
-  endif
+  rgb = max (0, rgb);
+  idx = any (rgb > 1, 2);
+  rgb(idx,:) = rgb(idx,:) ./ max (rgb(idx,:), [], 2);
 
   rgb = colorspace_conversion_revert (rgb, cls, sz, is_im, is_nd, is_int);
 endfunction