# HG changeset patch # User jwe # Date 1198135442 0 # Node ID d0784e593d39c67a69152d3a44e6e77673259d38 # Parent 9af6f0a214ee3088b47bb9541ba22a3bc77bd081 [project @ 2007-12-20 07:24:02 by jwe] diff -r 9af6f0a214ee -r d0784e593d39 scripts/ChangeLog --- a/scripts/ChangeLog Wed Dec 19 21:39:02 2007 +0000 +++ b/scripts/ChangeLog Thu Dec 20 07:24:02 2007 +0000 @@ -1,3 +1,8 @@ +2007-12-19 Soren Hauberg + + * image/imshow.m: Store uint8 images as doubles. Handle default + display ranges correctly. + 2007-12-19 Alexander Barth Peter A. Gustafson diff -r 9af6f0a214ee -r d0784e593d39 scripts/image/imshow.m --- a/scripts/image/imshow.m Wed Dec 19 21:39:02 2007 +0000 +++ b/scripts/image/imshow.m Thu Dec 20 07:24:02 2007 +0000 @@ -58,7 +58,7 @@ print_usage (); endif - display_range = []; + display_range = NA; true_color = false; indexed = false; @@ -116,7 +116,7 @@ endwhile ## Set default display range. - if (true_color || isempty (display_range)) + if (isempty (display_range)) display_range = [min(im(:)), max(im(:))]; else t = class (im); @@ -124,7 +124,10 @@ case {"double", "single", "logical"} display_range = [0, 1]; case {"int8", "int16", "int32", "uint8", "uint16", "uint32"} - display_range = [intmin(t), intmax(t)]; + ## 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)]); otherwise error ("imshow: invalid data type for image"); endswitch @@ -144,17 +147,15 @@ endif ## This is for compatibility. - if (ismember (class (im), {"int8", "int16", "uint32", "int32", "single"})) + if (! indexed || islogical (im)) im = double (im); endif ## Scale the image to the interval [0, 1] according to display_range. if (! (true_color || indexed || islogical (im))) - class (im) -im - low = display_range(1) - high = display_range(2) - im = (im-low)/(high-low) + low = display_range(1); + high = display_range(2); + im = (im-low)/(high-low); im(im < 0) = 0; im(im > 1) = 1; endif