Log file Viewer
Help
|
Karma
| Search:
#pil logs for Monday the 3rd of March, 2014
(
Back to #pil overview
) (
Back to channel listing
) (
Animate logs
)
[
17:06:51
] <
raincomplex
> greetings
[
17:07:19
] <
raincomplex
> i'm having trouble finding information on image modes, in particular the I mode
[
17:07:49
] <
wiredfool
> I is not well documented
[
17:07:55
] <
raincomplex
> in the docs it says it's 32-bit signed integer pixel values, but it appears i'm only getting values 0-255
[
17:07:58
] <
wiredfool
> what do you need to know
[
17:08:21
] <
wiredfool
> how are you making/gettin an I image?
[
17:08:38
] <
wiredfool
> convert doesn't expand the range
[
17:09:13
] <
raincomplex
> img = PIL.Image.open('image.jpg'); i = img.convert('I'); pa = i.load(); pa[x,y]...
[
17:09:25
] <
raincomplex
> what do you mean about convert, that sounds like it's probably my issue
[
17:09:39
] <
wiredfool
> so what convert does is essentially an int cast
[
17:10:06
] <
wiredfool
> if you're going bigger, it's just storing an char in an int
[
17:10:13
] <
wiredfool
> if you're going smaller, it truncates
[
17:10:20
] <
raincomplex
> so i'm only getting one channel?
[
17:10:33
] <
wiredfool
> (after going grayscale)
[
17:10:55
] <
wiredfool
> I is single channel gray
[
17:11:17
] <
raincomplex
> oh
[
17:11:47
] <
raincomplex
> is there a way to access the RGB as a 32-bit integer instead of tuples like in 'RGB' mode?
[
17:12:18
] <
raincomplex
> i'll preface this by saying that i'm just looking for a way to make this a little faster
[
17:12:24
] <
wiredfool
> ah
[
17:12:31
] <
raincomplex
> and there's probably an easier way to do that than this
[
17:12:35
] <
wiredfool
> probably
[
17:12:46
] <
wiredfool
> step back a bit, what are you trying to do
[
17:14:17
] <
raincomplex
> twiddle bits in an image
[
17:14:41
] <
raincomplex
> steganography type deal
[
17:15:00
] <
raincomplex
> post on reddit got me thinking about it, and i'd not used PIL before
[
17:15:09
] <
raincomplex
> (usually i use pygame for this sort of thing)
[
17:16:15
] <
wiredfool
> well, you can get the bytestream with tobytes()
[
17:16:47
] <
wiredfool
> there's also imagemath
[
17:17:25
] <
wiredfool
> generally, the fast path is letting the c layer do the looping over the pixels in the image
[
17:18:05
] <
raincomplex
> unfortunately the access path is random and determined by python code
[
17:18:11
] <
wiredfool
> alternately, if you use pypy and cffi and the HEAD version, the pixel access object is way faster
[
17:18:28
] <
wiredfool
> tho, I don't remember if it's significantly faster than in the c version
[
17:24:47
] <
wiredfool
> the other thing that might help is to dump it into numpy, e.g. im.toarray(), and then use numpy to work on it.
[
17:39:02
] <
raincomplex
> hm. profiling it, it seems like there's a fair amount of overhead just from the number of function calls
[
17:39:17
] <
raincomplex
> maybe i should let speed go for this, haha
[
17:39:26
] <
raincomplex
> can always have a fast version in C
[
18:22:10
] <
raincomplex
> thanks for the help wired :D