List Info

Thread: 3 channel float images




3 channel float images
user name
2006-07-11 18:32:58
I do work with high dynamic range images and would like to
see about  
extending PIL to support them.  For those unfamiliar, the
primary  
difference is that all the channels are floating point.

I've more or less deconstructed the way that the
importer/exporter  
code works, but wanted to check on what to do to be able to
create  
images that contain 3 floating point channels.

What all do I need to do?
+   Add an experimental mode?
+   Add a memory mapping?
+   Add a new case to storage.c?

Any pointers and help would be greatly appreciated.

Cheers
Matt

[  matthew m trentacoste                 mmtcs.ubc.ca
                ]
[                                                           
          ]
[  graduate student                      lead software
developer       ]
[  university of british columbia        brightside
technologies       ]
[  http://www.cs.ubc.ca/~mmt             http://brightsidetech.com     ]
[  +1 (604) 827-3979                     +1 (604) 228-4624  
          ]


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
3 channel float images
user name
2006-07-11 19:38:17
Matthew Trentacoste wrote:
> I do work with high dynamic range images and would like
to see about  
> extending PIL to support them.  For those unfamiliar,
the primary  
> difference is that all the channels are floating point.
> 
> I've more or less deconstructed the way that the
importer/exporter  
> code works, but wanted to check on what to do to be
able to create  
> images that contain 3 floating point channels.
> 
> What all do I need to do?
> +   Add an experimental mode?
> +   Add a memory mapping?
> +   Add a new case to storage.c?
> 
> Any pointers and help would be greatly appreciated.
> 

Use NumPy for storage.   Then you an use the scipy.ndimage
module or 
scipy.signal module for image processing.

-Travis

_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
3 channel float images
user name
2006-07-13 10:49:22
Matthew Trentacoste wrote:

> I do work with high dynamic range images and would like
to see about
> extending PIL to support them.  For those unfamiliar,
the primary
> difference is that all the channels are floating point.
>
> I've more or less deconstructed the way that the
importer/exporter
> code works, but wanted to check on what to do to be
able to create
> images that contain 3 floating point channels.
>
> What all do I need to do?
> +   Add an experimental mode?
> +   Add a memory mapping?
> +   Add a new case to storage.c?
>
> Any pointers and help would be greatly appreciated.


Hi Matt,

You might want to have a look at this:

  
http://starship.python.net/crew/schorsch/pilray.html

It's very old (PIL 1.0) and probably not very pretty, but
it
worked for what I needed at the time.

I had to create a custom RGBf mode because the existing F
mode is
single channel. If you should happen to work with the
Radiance
image format, then you could use my import/export code,
probably
with very little change. I would be happy to contribute that
to
the official PIL release, if Fredrik wants it.

I also experimented a bit with storing the data the same way
Radiance does (RGBE: four ints, the mantissa of each RGB
channel
and a common exponent), which would save a lot of space at a
slight computational expense. I don't remember why I
didn't
continue into that direction.

My attempts at tonemapping for converting into other image
formats are probably the ugliest part of the package. I used
some
code taken from Radiance, which was even less modular at the
time
than it is today. I think it is also easier to write
extensions
to PIL with newer versions, but haven't checked the details
yet.
In any case, this may be the part where you need to invest
the
most thought and effort to get something better than I did.


Good luck!

-schorsch

-- 
Georg Mischler  --  simulations developer  --  schorsch at
schorsch com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
3 channel float images
user name
2006-07-13 16:43:32
Georg Mischler wrote:

> I also experimented a bit with storing the data the
same way
> Radiance does (RGBE: four ints, the mantissa of each
RGB channel
> and a common exponent), which would save a lot of space
at a
> slight computational expense. I don't remember why I
didn't
> continue into that direction.


On checking, I just realized that my memory was faulty in
more
than one sense.  My code actually stores RGBE values, and
decodes
just where necessary (eg. in getpixel() etc.).

This has the advantage that it circumvents the storage
issues
Fredrik mentioned (whichever those actually are), and that
it
uses only a third of the memory.

It has the disadvantage that some of the internal filtering
operations won't give the expected result. You can't
interpolate
by just taking averages, for example, because the exponent
needs
to be treated differently. All operations that just copy
pixels
around will work fine, though.


-schorsch

-- 
Georg Mischler  --  simulations developer  --  schorsch at
schorsch com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/
_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )