open, show, png, blank

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

open, show, png, blank

Nelson Tong
I tried the following for a png file.

  outI = Image.open( fileOutPNGFile )
  outI.show();

The code run without error, but the image return via X-windows  on my
linux machine is a blank image, without visible graphic on it.

I am 100% positive that the image of fileOutPNGFile is not corrupted
because I am able to open it via the web-browser.

I tried the same code another to open  another png file which I use
PIL to draw and save as png.   The code above is able to open and show
this png file properly.

why dose this happen?
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

open, show, png, blank

Nelson Tong
Hi all,

I tried the following to process a png file,

 outI = Image.open( fileOutPNGFile )
 outI.show();

The code run without error, but the image return via X-windows  on my
linux machine is a blank image, without visible graphic on it.

I am 100% positive that the image of fileOutPNGFile is not corrupted
because I am able to open it via the web-browser.

I tried the same code another to open  another png file which I use
PIL to draw and save as png.   The code above is able to open and show
this png file properly.

why might this happen?
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Matthias Bock
Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:

>  outI = Image.open( fileOutPNGFile )
>  outI.show();
>
> The code run without error, but the image return via X-windows  on my
> linux machine is a blank image, without visible graphic on it.

What color is this "blank": Grey? White?
Does the size match the PNG size?

> I am 100% positive that the image of fileOutPNGFile is not corrupted
> because I am able to open it via the web-browser.

Web browsers can open corrupted image files.

> I tried the same code another to open  another png file which I use
> PIL to draw and save as png.   The code above is able to open and show
> this png file properly.

Sounds to me, as if the first PNG was broken.

Try this:

 outI = Image.open( fileOutPNGFile )
 outI.show()
 outI.save('test.png')
 out2 = Image.open('test.png')
 out2.show()

> why might this happen?

If the code doesn't help solving the issue,
could you send the PNG to the list?

Cheers, Matthias

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Nelson Tong
thanks for reply, Matthias,

when I use "show()", the image appears to have an all-white
background, nothing else is on it.  The size does indeed match the png
size , I used the following to confirm:

    x, y =  outIm.size
    print "size of outImg: " + str(x)+" " + str(y);

I tries to resave the png as a  png image with a different name using
PIL and show() of the 2nd png image still appear to have all-white
background with nothing on it.

but If I open the images (both the 1st and the re-saved image ) with
the command line command of "display", I can see the images via
ImageMagick.

Attached is example image which I am having problem with.  Can you
reproduce the same problem I'm seeing with this image, possibly due to
the png image being broken?

-N.


On 1/29/12, Matthias Bock <[hidden email]> wrote:

> Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:
>
>>  outI = Image.open( fileOutPNGFile )
>>  outI.show();
>>
>> The code run without error, but the image return via X-windows  on my
>> linux machine is a blank image, without visible graphic on it.
>
> What color is this "blank": Grey? White?
> Does the size match the PNG size?
>
>> I am 100% positive that the image of fileOutPNGFile is not corrupted
>> because I am able to open it via the web-browser.
>
> Web browsers can open corrupted image files.
>
>> I tried the same code another to open  another png file which I use
>> PIL to draw and save as png.   The code above is able to open and show
>> this png file properly.
>
> Sounds to me, as if the first PNG was broken.
>
> Try this:
>
>  outI = Image.open( fileOutPNGFile )
>  outI.show()
>  outI.save('test.png')
>  out2 = Image.open('test.png')
>  out2.show()
>
>> why might this happen?
>
> If the code doesn't help solving the issue,
> could you send the PNG to the list?
>
> Cheers, Matthias
>
>

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig

gcp.png (1M) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Chris Mitchell-2
Hey Nelson,

Are you sure this image isn't actually a tiff (Every gel scanner I've ever used outputs tiffs)?  Also, is it opening as an 8 bit image or a 16 bit?  For a gel scan, it should be a 16 bit image, so you can consider forcing the mode while opening it..

Chris

On Tue, Jan 31, 2012 at 1:38 PM, Nelson Tong <[hidden email]> wrote:
thanks for reply, Matthias,

when I use "show()", the image appears to have an all-white
background, nothing else is on it.  The size does indeed match the png
size , I used the following to confirm:

   x, y =  outIm.size
   print "size of outImg: " + str(x)+" " + str(y);

I tries to resave the png as a  png image with a different name using
PIL and show() of the 2nd png image still appear to have all-white
background with nothing on it.

but If I open the images (both the 1st and the re-saved image ) with
the command line command of "display", I can see the images via
ImageMagick.

Attached is example image which I am having problem with.  Can you
reproduce the same problem I'm seeing with this image, possibly due to
the png image being broken?

-N.


On 1/29/12, Matthias Bock <[hidden email]> wrote:
> Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:
>
>>  outI = Image.open( fileOutPNGFile )
>>  outI.show();
>>
>> The code run without error, but the image return via X-windows  on my
>> linux machine is a blank image, without visible graphic on it.
>
> What color is this "blank": Grey? White?
> Does the size match the PNG size?
>
>> I am 100% positive that the image of fileOutPNGFile is not corrupted
>> because I am able to open it via the web-browser.
>
> Web browsers can open corrupted image files.
>
>> I tried the same code another to open  another png file which I use
>> PIL to draw and save as png.   The code above is able to open and show
>> this png file properly.
>
> Sounds to me, as if the first PNG was broken.
>
> Try this:
>
>  outI = Image.open( fileOutPNGFile )
>  outI.show()
>  outI.save('test.png')
>  out2 = Image.open('test.png')
>  out2.show()
>
>> why might this happen?
>
> If the code doesn't help solving the issue,
> could you send the PNG to the list?
>
> Cheers, Matthias
>
>

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig



_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Randolph Bentson
In reply to this post by Nelson Tong
On Tue, Jan 31, 2012 at 01:38:25PM -0500, Nelson Tong wrote:
>
> when I use "show()", the image appears to have an all-white
> background, nothing else is on it.
...
> Attached is example image which I am having problem with.  Can you
> reproduce the same problem I'm seeing with this image, possibly due to
> the png image being broken?
...
> > Try this:
> >
> >  outI = Image.open( fileOutPNGFile )

There's some faulty magic at the core of this problem. When the file
you cited goes through "outI = Image.open( fileOutPNGFile )", the open
method notes all the pixels are shades of gray, so the internal image is
converted to a grayscale form. For example, "outI.getbands()" reports
"('I',)" instead of "('R','G','B')".

The command "outI.getextrema()" returns (8200,60602).  So when the image
is saved as a pbm file for display, the shades of gray are all rendered
as white when all the pixels are being converted to the (R,G,B) value of
(255,255,255). This flaw is related to the conversion of the grayscale
format.  If one executes "outI.save("altfile.png") the resulting file
looks like the original (for some reason), but "tmpJ.getpixel((x,y))"
where "tmpJ=outI.convert("RGB")" returns (255,255,255) for all x,y.

If you insert the line "outI = outI.point(lambda i:i * .0039062500 + 0)"
the I mode gets scaled down so the conversion to 'RGB' mode is
valid.

--
Randolph Bentson
[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Randolph Bentson
In reply to this post by Nelson Tong
Oh, I guess the lambda function should be generalized by

(lo,hi) = outI.getextrema()
x = 256.0/(hi-lo)
y = (0-lo)/256.0
outJ = outI.point(lambda i:i*x+y)

--
Randolph Bentson
[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Matthias Bock
In reply to this post by Chris Mitchell-2
It really is a PNG and it's 16-bit grayscale.

 $ file gcp.png
gcp.png: PNG image data, 1024 x 768, 16-bit grayscale, non-interlaced

I can reproduce, the blank white show() output,
which clearly is a bug in PIL.

PIL opens it in "I" mode
 print im.mode
which means "integer", but I don't know whether this is correct
or not. Maybe "I;16" or so could be tried.
See http://svn.effbot.org/public/tags/pil-1.1.4/libImaging/Unpack.c
for possible modes.

QuickFix: Make a JPG.
 $ convert gcp.png gcp.jpg

 ...
 im = Image.open('gcp.jpg')
 ...

Have a nice day,
Matthias

Am Samstag, den 04.02.2012, 10:58 -0500 schrieb Chris Mitchell:

> Hey Nelson,
>
> Are you sure this image isn't actually a tiff (Every gel scanner I've ever
> used outputs tiffs)?  Also, is it opening as an 8 bit image or a 16 bit?
>  For a gel scan, it should be a 16 bit image, so you can consider forcing
> the mode while opening it..
>
> Chris
>
> On Tue, Jan 31, 2012 at 1:38 PM, Nelson Tong <[hidden email]>wrote:
>
> > thanks for reply, Matthias,
> >
> > when I use "show()", the image appears to have an all-white
> > background, nothing else is on it.  The size does indeed match the png
> > size , I used the following to confirm:
> >
> >    x, y =  outIm.size
> >    print "size of outImg: " + str(x)+" " + str(y);
> >
> > I tries to resave the png as a  png image with a different name using
> > PIL and show() of the 2nd png image still appear to have all-white
> > background with nothing on it.
> >
> > but If I open the images (both the 1st and the re-saved image ) with
> > the command line command of "display", I can see the images via
> > ImageMagick.
> >
> > Attached is example image which I am having problem with.  Can you
> > reproduce the same problem I'm seeing with this image, possibly due to
> > the png image being broken?
> >
> > -N.
> >
> >
> > On 1/29/12, Matthias Bock <[hidden email]> wrote:
> > > Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:
> > >
> > >>  outI = Image.open( fileOutPNGFile )
> > >>  outI.show();
> > >>
> > >> The code run without error, but the image return via X-windows  on my
> > >> linux machine is a blank image, without visible graphic on it.
> > >
> > > What color is this "blank": Grey? White?
> > > Does the size match the PNG size?
> > >
> > >> I am 100% positive that the image of fileOutPNGFile is not corrupted
> > >> because I am able to open it via the web-browser.
> > >
> > > Web browsers can open corrupted image files.
> > >
> > >> I tried the same code another to open  another png file which I use
> > >> PIL to draw and save as png.   The code above is able to open and show
> > >> this png file properly.
> > >
> > > Sounds to me, as if the first PNG was broken.
> > >
> > > Try this:
> > >
> > >  outI = Image.open( fileOutPNGFile )
> > >  outI.show()
> > >  outI.save('test.png')
> > >  out2 = Image.open('test.png')
> > >  out2.show()
> > >
> > >> why might this happen?
> > >
> > > If the code doesn't help solving the issue,
> > > could you send the PNG to the list?
> > >
> > > Cheers, Matthias
> > >
> > >


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Nelson Tong
thanks for the replies, everyone

I think I am going to try do what i need to do using jpg instead of png for now.

The funny thing is  this piece of code I am now trying to run used to
work  with those kind of gel png in the past when I have this
installed in an old server:

python-imaging-devel-1.1.6-3.fc7



On 2/5/12, Matthias Bock <[hidden email]> wrote:

> It really is a PNG and it's 16-bit grayscale.
>
>  $ file gcp.png
> gcp.png: PNG image data, 1024 x 768, 16-bit grayscale, non-interlaced
>
> I can reproduce, the blank white show() output,
> which clearly is a bug in PIL.
>
> PIL opens it in "I" mode
>  print im.mode
> which means "integer", but I don't know whether this is correct
> or not. Maybe "I;16" or so could be tried.
> See http://svn.effbot.org/public/tags/pil-1.1.4/libImaging/Unpack.c
> for possible modes.
>
> QuickFix: Make a JPG.
>
>  ...
>  im = Image.open('gcp.jpg')
>  ...
>
> Have a nice day,
> Matthias
>
> Am Samstag, den 04.02.2012, 10:58 -0500 schrieb Chris Mitchell:
>> Hey Nelson,
>>
>> Are you sure this image isn't actually a tiff (Every gel scanner I've ever
>> used outputs tiffs)?  Also, is it opening as an 8 bit image or a 16 bit?
>>  For a gel scan, it should be a 16 bit image, so you can consider forcing
>> the mode while opening it..
>>
>> Chris
>>
>> On Tue, Jan 31, 2012 at 1:38 PM, Nelson Tong
>> <[hidden email]>wrote:
>>
>> > thanks for reply, Matthias,
>> >
>> > when I use "show()", the image appears to have an all-white
>> > background, nothing else is on it.  The size does indeed match the png
>> > size , I used the following to confirm:
>> >
>> >    x, y =  outIm.size
>> >    print "size of outImg: " + str(x)+" " + str(y);
>> >
>> > I tries to resave the png as a  png image with a different name using
>> > PIL and show() of the 2nd png image still appear to have all-white
>> > background with nothing on it.
>> >
>> > but If I open the images (both the 1st and the re-saved image ) with
>> > the command line command of "display", I can see the images via
>> > ImageMagick.
>> >
>> > Attached is example image which I am having problem with.  Can you
>> > reproduce the same problem I'm seeing with this image, possibly due to
>> > the png image being broken?
>> >
>> > -N.
>> >
>> >
>> > On 1/29/12, Matthias Bock <[hidden email]> wrote:
>> > > Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:
>> > >
>> > >>  outI = Image.open( fileOutPNGFile )
>> > >>  outI.show();
>> > >>
>> > >> The code run without error, but the image return via X-windows  on my
>> > >> linux machine is a blank image, without visible graphic on it.
>> > >
>> > > What color is this "blank": Grey? White?
>> > > Does the size match the PNG size?
>> > >
>> > >> I am 100% positive that the image of fileOutPNGFile is not corrupted
>> > >> because I am able to open it via the web-browser.
>> > >
>> > > Web browsers can open corrupted image files.
>> > >
>> > >> I tried the same code another to open  another png file which I use
>> > >> PIL to draw and save as png.   The code above is able to open and
>> > >> show
>> > >> this png file properly.
>> > >
>> > > Sounds to me, as if the first PNG was broken.
>> > >
>> > > Try this:
>> > >
>> > >  outI = Image.open( fileOutPNGFile )
>> > >  outI.show()
>> > >  outI.save('test.png')
>> > >  out2 = Image.open('test.png')
>> > >  out2.show()
>> > >
>> > >> why might this happen?
>> > >
>> > > If the code doesn't help solving the issue,
>> > > could you send the PNG to the list?
>> > >
>> > > Cheers, Matthias
>> > >
>> > >
>
>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Nelson Tong
In reply to this post by Randolph Bentson
Thanks Randolph.

this solution does indeed work for me.   The mapping function just
manages to manipulate the pixel values enough so that png image can be
opened  and be pasted onto other images without become blank.

lambda i:i * .0039062500 + 0

how important is the use of the generalized mapping function in here?
does the  scale and offset of function definitely needs to be adjusted
if every image I want to process is similar to each other in terms of
min and max values?



On 2/4/12, Randolph Bentson <[hidden email]> wrote:

> Oh, I guess the lambda function should be generalized by
>
> (lo,hi) = outI.getextrema()
> x = 256.0/(hi-lo)
> y = (0-lo)/256.0
> outJ = outI.point(lambda i:i*x+y)
>
> --
> Randolph Bentson
> [hidden email]
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Randolph Bentson
On Wed, Feb 08, 2012 at 02:31:37PM -0500, Nelson Tong wrote:

> Thanks Randolph.
>
> this solution does indeed work for me.   The mapping function just
> manages to manipulate the pixel values enough so that png image can be
> opened  and be pasted onto other images without become blank.
>
> lambda i:i * .0039062500 + 0
>
> how important is the use of the generalized mapping function in here?
> does the  scale and offset of function definitely needs to be adjusted
> if every image I want to process is similar to each other in terms of
> min and max values?
>
> On 2/4/12, Randolph Bentson <[hidden email]> wrote:
> > Oh, I guess the lambda function should be generalized by
> >
> > (lo,hi) = outI.getextrema()
> > x = 256.0/(hi-lo)
> > y = (0-lo)/256.0
> > outJ = outI.point(lambda i:i*x+y)

I have no experience with these type images, so I don't know if
constant values are appropriate. The performance of the generalized
mapping seems quick enough, so that may be safer.  BUT, there's
one questionable issue with this function: it turns the darkest
source pixel to black and the lightest pixel to white. I hope
others can provide some comments on that.

--
Randolph Bentson
[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Nelson Tong
>>
>> On 2/4/12, Randolph Bentson <[hidden email]> wrote:
>> > Oh, I guess the lambda function should be generalized by
>> >
>> > (lo,hi) = outI.getextrema()
>> > x = 256.0/(hi-lo)
>> > y = (0-lo)/256.0
>> > outJ = outI.point(lambda i:i*x+y)
>
> I have no experience with these type images, so I don't know if
> constant values are appropriate. The performance of the generalized
> mapping seems quick enough, so that may be safer.  BUT, there's
> one questionable issue with this function: it turns the darkest
> source pixel to black and the lightest pixel to white. I hope
> others can provide some comments on that.

I'm not an expert in image processing.  I just want to learn more
about this since we are talking about the mapping function here.

I don't quite completely understand how this generalized mapping
function work with im.point().  Given the hi and lo from getextema(),
I understand that x = 256.0/(hi-lo)
 is a way to  to adjust the scale parameter to the have a range of
values  from 0 to 256.  but where does the offset of (y= (0-lo) /256 )
comes from ? is there any reference anyone can recommend as a tutorial
about this kind of mapping function?








>
> --
> Randolph Bentson
> [hidden email]
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Chris Mitchell-2
>From my understanding of what you are trying to do is remap the dynamic range of your image.  So in essence you want to set your lowest intensity to 0 and the highest to 256 (given an 8 bit image).  The transformation given is non-linear, if you are using this for gel quantification this is a very very very bad idea.  If it's just screwing around, then it's fine.

So first you say what is the range, (hi-lo), and divide 256 by this to give your effective intensity per value within your range (so taking a low of 100, a max of 250, each 'point' now represents 1.70 intensity).  You also want to subtract the lowest intensity from each point to make your new effective "0 intensity".  This is done dynamically by your given y equation.  For a linear equation, you would want do use this:

outJ = outI.point(lambda i:(i-y)*x)
So all pixels which were 100 should now map to 0, a pixel of 250 would map to 255.

On Thu, Feb 9, 2012 at 12:16 PM, Nelson Tong <[hidden email]> wrote:
>>
>> On 2/4/12, Randolph Bentson <[hidden email]> wrote:
>> > Oh, I guess the lambda function should be generalized by
>> >
>> > (lo,hi) = outI.getextrema()
>> > x = 256.0/(hi-lo)
>> > y = (0-lo)/256.0
>> > outJ = outI.point(lambda i:i*x+y)
>
> I have no experience with these type images, so I don't know if
> constant values are appropriate. The performance of the generalized
> mapping seems quick enough, so that may be safer.  BUT, there's
> one questionable issue with this function: it turns the darkest
> source pixel to black and the lightest pixel to white. I hope
> others can provide some comments on that.

I'm not an expert in image processing.  I just want to learn more
about this since we are talking about the mapping function here.

I don't quite completely understand how this generalized mapping
function work with im.point().  Given the hi and lo from getextema(),
I understand that x = 256.0/(hi-lo)
 is a way to  to adjust the scale parameter to the have a range of
values  from 0 to 256.  but where does the offset of (y= (0-lo) /256 )
comes from ? is there any reference anyone can recommend as a tutorial
about this kind of mapping function?








>
> --
> Randolph Bentson
> [hidden email]
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Randolph Bentson
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
[hidden email]
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: open, show, png, blank

Chris Mitchell-2
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 <[hidden email]> 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
[hidden email]


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig