# HG changeset patch # User jwe # Date 976904356 0 # Node ID 574711ce9070250ae3dfc1dc75f4df33ed11f8dd # Parent 41404c6f4e69046fc89a4911e1bfa9ffb388ae71 [project @ 2000-12-15 18:19:15 by jwe] diff -r 41404c6f4e69 -r 574711ce9070 liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Dec 15 03:14:45 2000 +0000 +++ b/liboctave/ChangeLog Fri Dec 15 18:19:16 2000 +0000 @@ -1,3 +1,9 @@ +2000-12-15 John W. Eaton + + * lo-mappers.cc (xmin (const Complex&, const Complex& y): + If args are equal in magnitude, return first arg instead of + second. + 2000-12-13 John W. Eaton * Range.cc (Range::nelem_internal): Call tfloor, not round, but diff -r 41404c6f4e69 -r 574711ce9070 liboctave/lo-mappers.cc --- a/liboctave/lo-mappers.cc Fri Dec 15 03:14:45 2000 +0000 +++ b/liboctave/lo-mappers.cc Fri Dec 15 18:19:16 2000 +0000 @@ -315,13 +315,13 @@ Complex xmin (const Complex& x, const Complex& y) { - return abs (x) < abs (y) ? x : (xisnan (x) ? x : y); + return abs (x) <= abs (y) ? x : (xisnan (x) ? x : y); } Complex xmax (const Complex& x, const Complex& y) { - return abs (x) > abs (y) ? x : (xisnan (x) ? x : y); + return abs (x) >= abs (y) ? x : (xisnan (x) ? x : y); } /* diff -r 41404c6f4e69 -r 574711ce9070 scripts/ChangeLog --- a/scripts/ChangeLog Fri Dec 15 03:14:45 2000 +0000 +++ b/scripts/ChangeLog Fri Dec 15 18:19:16 2000 +0000 @@ -1,3 +1,8 @@ +2000-12-15 Kai Habel + + * saveimage.m: Do create rawbit image for black and white images, + but do it correctly. + 2000-12-13 Teemu Ikonen * polynomial/deconv.m: For compatibility with Matlab, don't reduce diff -r 41404c6f4e69 -r 574711ce9070 scripts/image/saveimage.m --- a/scripts/image/saveimage.m Fri Dec 15 03:14:45 2000 +0000 +++ b/scripts/image/saveimage.m Fri Dec 15 18:19:16 2000 +0000 @@ -133,6 +133,10 @@ map = round (255 * map); + bw = (map_nr == 2 + && ((map(1,1) == 0 && map(2,1) == 255) + || (map(1,1) == 255 && map(2,1) == 0))); + img = round (img'); [img_nr, img_nc] = size (img); @@ -156,7 +160,38 @@ tagline = sprintf ("# Created by Octave %s, %s", __OCTAVE_VERSION__, time_string); - if (grey) + if (grey && bw) + + if (map(1) != 0) + map = [0; 1]; + else + map = [1; 0]; + endif + + n_long = rem (img_nc, 8); + tmp = zeros (ceil (img_nc/8), img_nr); + + k = ceil (img_nr/8); + tmp = zeros (k, img_nc); + + ## Append columns with zeros to original image so that + ## mod (cols, 8) = 0. + + bwimg = postpad (reshape (map(img), img_nr, img_nc), k * 8, 0); + + b = kron (pow2 (7:-1:0)', ones (1, img_nc)); + + for i = 1:k + tmp(i,:) = sum (bwimg(8*(i-1)+1:8*i,:) .* b); + endfor + + fid = fopen (filename, "w"); + fprintf (fid, "P4\n%s\n%d %d\n", tagline, img_nr, img_nc); + fwrite (fid, tmp, "char"); + fprintf (fid, "\n"); + fclose (fid); + + elseif (grey) fid = fopen (filename, "w"); fprintf (fid, "P5\n%s\n%d %d\n255\n", tagline, img_nr, img_nc);