I did mean to subtract -lo.  I used y because the initial definition used y
as the lowest point.  For your second comment, I don't get the difference.
you still have 256 separate gradations.

On Thu, Feb 9, 2012 at 5:48 PM, Randolph Bentson <bent...@holmsjoen.com>wrote:

> On Thu, Feb 09, 2012 at 12:40:49PM -0500, Chris Mitchell wrote:
> > For a linear equation, you would want do use this:
> >
> > outJ = outI.point(lambda i:(i-y)*x)
>
> I think this should be outJ = outI.point(lambda i:(i-lo)*x), but the
> point conversion method doesn't deal with these lambda definitions.
> My definition of y should have been "y = -lo*x" which brings my
> code to an algebraic equivalent to what I think Chris intends.
>
> This point conversion is only appropriate for use of the show
> method of the new image.  Although outJ.show() creates a properly
> formed Netpbm PGM "rawbits" image, if outJ is saved, the resulting
> grayscale png file is black because it's a grayscale image which
> has been scaled down a lot.
>
> The single statement
>  outI.point(lambda i:i*x+y).show()
> avoids the temptation to save the rescaled image. :-)
>
> -----------------------------------------------------
>
> Although this design gives a non-white image, it is flawed in that
> the displayed image has greater contrast than the original. This
> is because the image under discussion doesn't use the full 16 bit
> "I" mode range of 0 to 65535. My code maps a lesser source range
> to 0 to 255 instead of 32 to 236 which would preserve the contrast.
>
> So I propose a revised solution
>  scale = 256.0/2**16
>  outI.point(lambda i:i*scale+0).show()
>
> This relies on the "I" mode image having 16 bit pixels. I couldn't
> find a way to determine the source pixel size in PIL. The description
> of "I" mode in pil-handbook.pdf says it's 32 bit, which suggests
> other grayscale files may use other pixel sizes.
>
> --
> Randolph Bentson
> bent...@holmsjoen.com
>
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to