# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1295630881 21600 # Node ID e75c10ded26358fad6f651c306e6f3de7710ae47 # Parent 5ec6aa05638dd34b09a4ec4bb32803a0d6e2b583 set clim to [0,1] so that scaled cdatamapping works as intended. diff -r 5ec6aa05638d -r e75c10ded263 scripts/ChangeLog --- a/scripts/ChangeLog Thu Jan 20 21:29:14 2011 -0800 +++ b/scripts/ChangeLog Fri Jan 21 11:28:01 2011 -0600 @@ -270,6 +270,10 @@ Remove unneeded white spaces. * plot/uigetfile.m, plot/uiputfile.m: Remove unneeded white spaces. Bug #32190. +2011-01-20 Jordi GutiƩrrez Hermoso + + * image/imshow.m: Fix handling of clim and display_range so that + images are more faithfully reproduced. 2011-01-20 John W. Eaton diff -r 5ec6aa05638d -r e75c10ded263 scripts/image/imshow.m --- a/scripts/image/imshow.m Thu Jan 20 21:29:14 2011 -0800 +++ b/scripts/image/imshow.m Fri Jan 21 11:28:01 2011 -0600 @@ -124,10 +124,7 @@ case {"double", "single", "logical"} display_range = [0, 1]; case {"int8", "int16", "int32", "uint8", "uint16", "uint32"} - ## For compatibility, uint8 data should not be handled as - ## double. Doing so is a quick fix to allow the images to be - ## displayed correctly. - display_range = double ([intmin(t), intmax(t)]); + display_range = [intmin(imtype), intmax(imtype)]; otherwise error ("imshow: invalid data type for image"); endswitch @@ -151,13 +148,12 @@ im = double (im); endif - ## Scale the image to the interval [0, 1] according to display_range. + ## Clamp the image to the range boundaries if (! (true_color || indexed || islogical (im))) low = display_range(1); high = display_range(2); - im = (im-low)/(high-low); - im(im < 0) = 0; - im(im > 1) = 1; + im(im < low) = low; + im(im > high) = high; endif if (true_color || indexed) @@ -165,6 +161,8 @@ else tmp = image (im); set (tmp, "cdatamapping", "scaled"); + ## The backend is responsible for scaling to clim if necessary. + set (gca (), "clim", display_range); endif set (gca (), "visible", "off", "ydir", "reverse"); axis ("image");