Mercurial > hg > octave-nkf
changeset 3757:574711ce9070
[project @ 2000-12-15 18:19:15 by jwe]
author | jwe |
---|---|
date | Fri, 15 Dec 2000 18:19:16 +0000 |
parents | 41404c6f4e69 |
children | a816be1d1626 |
files | liboctave/ChangeLog liboctave/lo-mappers.cc scripts/ChangeLog scripts/image/saveimage.m |
diffstat | 4 files changed, 49 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,9 @@ +2000-12-15 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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 <jwe@bevo.che.wisc.edu> * Range.cc (Range::nelem_internal): Call tfloor, not round, but
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -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); } /*
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2000-12-15 Kai Habel <kai.habel@gmx.de> + + * saveimage.m: Do create rawbit image for black and white images, + but do it correctly. + 2000-12-13 Teemu Ikonen <tpikonen@pcu.helsinki.fi> * polynomial/deconv.m: For compatibility with Matlab, don't reduce
--- a/scripts/image/saveimage.m +++ b/scripts/image/saveimage.m @@ -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);