# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1295633738 18000 # Node ID a066673566da7c60fd80a30fe38263ba9ebaea57 # Parent a9cf422ed849ac6f4efe4b9cec03b3ec7e2a51fd set clim to [0,1] so that scaled cdatamapping works as intended. diff -r a9cf422ed849 -r a066673566da scripts/ChangeLog --- a/scripts/ChangeLog Fri Jan 21 11:05:21 2011 -0500 +++ b/scripts/ChangeLog Fri Jan 21 13:15:38 2011 -0500 @@ -1,3 +1,8 @@ +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 Rik * scripts/image/imshow.m, scripts/image/saveimage.m, diff -r a9cf422ed849 -r a066673566da scripts/image/imshow.m --- a/scripts/image/imshow.m Fri Jan 21 11:05:21 2011 -0500 +++ b/scripts/image/imshow.m Fri Jan 21 13:15:38 2011 -0500 @@ -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(t), intmax(t)]; 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");