Mercurial > octave
diff scripts/image/private/colorspace_conversion_input_check.m @ 20665:67e6343cd29a
Add support for colorspace conversion of signed integers images (patch #8709)
* scripts/image/private/colorspace_conversion_input_check.m: add support for
signed integers. 16 bit signed integers are common and supported by the
image package. We might as well support 8 bit signed as well.
* scripts/image/hsv2rgb.m, scripts/image/rgb2hsv.m, scripts/image/rgb2ntsc.m:
add tests for signed integer images.
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Wed, 28 Oct 2015 22:34:43 +0000 |
parents | a5ed88c9eb14 |
children | 1672bb8882dd |
line wrap: on
line diff
--- a/scripts/image/private/colorspace_conversion_input_check.m Wed Oct 28 19:51:02 2015 +0000 +++ b/scripts/image/private/colorspace_conversion_input_check.m Wed Oct 28 22:34:43 2015 +0000 @@ -29,7 +29,8 @@ ## If we have an image convert it into a color map. if (! iscolormap (in_arg)) - if (! any (strcmp (cls, {"uint8", "uint16", "single", "double"}))) + if (! any (strcmp (cls, {"uint8", "int8", "int16", "uint16", ... + "single", "double"}))) error ("%s: %s of invalid data type '%s'", func, arg_name, cls); elseif (size (in_arg, 3) != 3) error ("%s: %s must be a colormap or %s image", func, arg_name, arg_name); @@ -62,7 +63,13 @@ ## Convert to floating point (remember to leave class single alone) if (isinteger (in_arg)) - in_arg = double (in_arg) / double (intmax (cls)); + int_max = double (intmax (cls)); + int_min = double (intmin (cls)); + if (int_min < 0) + in_arg = (double (in_arg) - int_min) / (int_max - int_min); + else + in_arg = double (in_arg) / int_max; + endif endif endfunction