[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: imwrite for double grayvalues fails (regression)
From: |
Mike Miller |
Subject: |
Re: imwrite for double grayvalues fails (regression) |
Date: |
Thu, 3 Oct 2013 22:26:15 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Oct 04, 2013 at 00:12:11 +0200, Andreas Weber wrote:
> Dear maintainers,
> after changeset b76b14e386b3
> (http://hg.savannah.gnu.org/hgweb/octave/rev/b76b14e386b3?revcount=120)
>
> imwrite with grayvalues in the range 0..1 produces a black image.
>
> For example
>
> a=repmat(linspace(0,1,200),100,1);
> imwrite(a, test.png)
>
> should give a image wich fades horizontally from black to white.
> This is because (1 << bitdepth) gives an int overflow for bitdepth=32.
>
> Should we use a long int:
> const double divisor = static_cast<double>((1L << bitdepth) - 1) / MaxRGB;
>
> or is there a better fix?
I made this fix instead (1L still isn't wide enough on a 32-bit cpu):
http://hg.savannah.gnu.org/hgweb/octave/rev/b41860a0bc24
Thanks for finding and identifying this problem.
I tried to come up with a test case to add to imwrite using a floating
point image, but I got nothing. Any ideas?
--
mike