Modifying the hue and saturation of an image

Hello,

I would like to display an image, and to change its hue and saturation
while its displayed on the screen. Which classes/functions would be a
good choice for doing this?

Ram.

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

cool-RR wrote:

I would like to display an image, and to change its hue and saturation
while its displayed on the screen. Which classes/functions would be a
good choice for doing this?

I'd see if PIL supports this kind of thing -- you'll find notes about converting between PIL images an wx Images in the Wiki.

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Ah, I was hoping not to pull out the big guns for this one. I saw that wx.Image has some abilities to tweak images. Do you think I can do this on pure wxPython?

Ram.

···

On Mon, May 3, 2010 at 11:07 PM, Christopher Barker Chris.Barker@noaa.gov wrote:

cool-RR wrote:

I would like to display an image, and to change its hue and saturation

while its displayed on the screen. Which classes/functions would be a

good choice for doing this?

I’d see if PIL supports this kind of thing – you’ll find notes about converting between PIL images an wx Images in the Wiki.

-CHB

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

wx.lib.imageutils has some similar functions, which probably will show you enough to write your own method. I’ve used “grayOut” before and I suspect that’s pretty close to what you’re looking for. Haven’t tried using it interactively thought - it loops through every pixel in Python, so it’s probably pretty slow.

-Nat

···

On Mon, May 3, 2010 at 2:16 PM, cool-RR cool-rr@cool-rr.com wrote:

Ah, I was hoping not to pull out the big guns for this one. I saw that wx.Image has some abilities to tweak images. Do you think I can do this on pure wxPython?

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

I looked at it and it does not look pretty… I think it (a) doesn’t let me do what I want and (b) would be too slow.

Ram.

···

On Mon, May 3, 2010 at 11:20 PM, Nathaniel Echols nathaniel.echols@gmail.com wrote:

On Mon, May 3, 2010 at 2:16 PM, cool-RR cool-rr@cool-rr.com wrote:

Ah, I was hoping not to pull out the big guns for this one. I saw that wx.Image has some abilities to tweak images. Do you think I can do this on pure wxPython?

wx.lib.imageutils has some similar functions, which probably will show you enough to write your own method. I’ve used “grayOut” before and I suspect that’s pretty close to what you’re looking for. Haven’t tried using it interactively thought - it loops through every pixel in Python, so it’s probably pretty slow.

-Nat

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Since I see no easy solution I decided to give up on this task. Thanks for helping.

Ram.

···

On Mon, May 3, 2010 at 11:26 PM, cool-RR cool-rr@cool-rr.com wrote:

On Mon, May 3, 2010 at 11:20 PM, Nathaniel Echols nathaniel.echols@gmail.com wrote:

On Mon, May 3, 2010 at 2:16 PM, cool-RR cool-rr@cool-rr.com wrote:

Ah, I was hoping not to pull out the big guns for this one. I saw that wx.Image has some abilities to tweak images. Do you think I can do this on pure wxPython?

wx.lib.imageutils has some similar functions, which probably will show you enough to write your own method. I’ve used “grayOut” before and I suspect that’s pretty close to what you’re looking for. Haven’t tried using it interactively thought - it loops through every pixel in Python, so it’s probably pretty slow.

-Nat

I looked at it and it does not look pretty… I think it (a) doesn’t let me do what I want and (b) would be too slow.

Ram.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

There is wx.Image.RotateHue, not sure if that's what you want though. You can see the C++ implementation here: wxTrac has been migrated to GitHub Issues - wxWidgets

If that's not what you want then manipulating hue and saturation is basically just some math[1] performed on each pixel, and numpy does array based math really well and really fast. So one possibility would be to take a bitmap, use CopyToBuffer to put the pixel data into a numpy array, do the math using numpy magic, and then use CopyFromBuffer to move the data back into the bitmap.

I don't know what the speed would be like, but it will certainly be faster than looping over the pixels in Python code.

[1] Discovering what is the actual math to use is left as an exercise for the reader. :wink:

···

On 5/3/10 6:20 PM, cool-RR wrote:

On Mon, May 3, 2010 at 11:26 PM, cool-RR <cool-rr@cool-rr.com > <mailto:cool-rr@cool-rr.com>> wrote:

    On Mon, May 3, 2010 at 11:20 PM, Nathaniel Echols > <nathaniel.echols@gmail.com <mailto:nathaniel.echols@gmail.com>> wrote:

        On Mon, May 3, 2010 at 2:16 PM, cool-RR <cool-rr@cool-rr.com > <mailto:cool-rr@cool-rr.com>> wrote:

            Ah, I was hoping not to pull out the big guns for this one.
            I saw that `wx.Image` has some abilities to tweak images. Do
            you think I can do this on pure wxPython?

        wx.lib.imageutils has some similar functions, which probably
        will show you enough to write your own method. I've used
        "grayOut" before and I suspect that's pretty close to what
        you're looking for. Haven't tried using it interactively
        thought - it loops through every pixel in Python, so it's
        probably pretty slow.

        -Nat

    I looked at it and it does not look pretty... I think it (a) doesn't
    let me do what I want and (b) would be too slow.

    Ram.

Since I see no easy solution I decided to give up on this task. Thanks
for helping.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks Robin. The RotateHue thing is actually one of the things I wanted, but I’ll also need ability to change saturation, and I don’t want to use an external module for this one, so I think I’ll just let it go.

Ram.

···

On Tue, May 4, 2010 at 5:00 AM, Robin Dunn robin@alldunn.com wrote:

On 5/3/10 6:20 PM, cool-RR wrote:

On Mon, May 3, 2010 at 11:26 PM, cool-RR <cool-rr@cool-rr.com > > mailto:cool-rr@cool-rr.com> wrote:

On Mon, May 3, 2010 at 11:20 PM, Nathaniel Echols > > <nathaniel.echols@gmail.com <mailto:nathaniel.echols@gmail.com>> wrote:



    On Mon, May 3, 2010 at 2:16 PM, cool-RR <cool-rr@cool-rr.com > > <mailto:cool-rr@cool-rr.com>> wrote:



        Ah, I was hoping not to pull out the big guns for this one.

        I saw that `wx.Image` has some abilities to tweak images. Do

        you think I can do this on pure wxPython?





    wx.lib.imageutils has some similar functions, which probably

    will show you enough to write your own method.  I've used

    "grayOut" before and I suspect that's pretty close to what

    you're looking for.  Haven't tried using it interactively

    thought - it loops through every pixel in Python, so it's

    probably pretty slow.



    -Nat





I looked at it and it does not look pretty... I think it (a) doesn't

let me do what I want and (b) would be too slow.



Ram.

Since I see no easy solution I decided to give up on this task. Thanks

for helping.

There is wx.Image.RotateHue, not sure if that’s what you want though. You can see the C++ implementation here: http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/common/image.cpp#L2768

If that’s not what you want then manipulating hue and saturation is basically just some math[1] performed on each pixel, and numpy does array based math really well and really fast. So one possibility would be to take a bitmap, use CopyToBuffer to put the pixel data into a numpy array, do the math using numpy magic, and then use CopyFromBuffer to move the data back into the bitmap.

I don’t know what the speed would be like, but it will certainly be faster than looping over the pixels in Python code.

[1] Discovering what is the actual math to use is left as an exercise for the reader. :wink:

Robin Dunn

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Update: I actually used it now and it works quite well.

Ram.

···

On Tue, May 4, 2010 at 1:06 PM, cool-RR cool-rr@cool-rr.com wrote:

On Tue, May 4, 2010 at 5:00 AM, Robin Dunn robin@alldunn.com wrote:

On 5/3/10 6:20 PM, cool-RR wrote:

On Mon, May 3, 2010 at 11:26 PM, cool-RR <cool-rr@cool-rr.com > > > mailto:cool-rr@cool-rr.com> wrote:

On Mon, May 3, 2010 at 11:20 PM, Nathaniel Echols > > > <nathaniel.echols@gmail.com <mailto:nathaniel.echols@gmail.com>> wrote:



    On Mon, May 3, 2010 at 2:16 PM, cool-RR <cool-rr@cool-rr.com > > > <mailto:cool-rr@cool-rr.com>> wrote:



        Ah, I was hoping not to pull out the big guns for this one.

        I saw that `wx.Image` has some abilities to tweak images. Do

        you think I can do this on pure wxPython?





    wx.lib.imageutils has some similar functions, which probably

    will show you enough to write your own method.  I've used

    "grayOut" before and I suspect that's pretty close to what

    you're looking for.  Haven't tried using it interactively

    thought - it loops through every pixel in Python, so it's

    probably pretty slow.



    -Nat





I looked at it and it does not look pretty... I think it (a) doesn't

let me do what I want and (b) would be too slow.



Ram.

Since I see no easy solution I decided to give up on this task. Thanks

for helping.

There is wx.Image.RotateHue, not sure if that’s what you want though. You can see the C++ implementation here: http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/common/image.cpp#L2768

If that’s not what you want then manipulating hue and saturation is basically just some math[1] performed on each pixel, and numpy does array based math really well and really fast. So one possibility would be to take a bitmap, use CopyToBuffer to put the pixel data into a numpy array, do the math using numpy magic, and then use CopyFromBuffer to move the data back into the bitmap.

I don’t know what the speed would be like, but it will certainly be faster than looping over the pixels in Python code.

[1] Discovering what is the actual math to use is left as an exercise for the reader. :wink:

Robin Dunn

Thanks Robin. The RotateHue thing is actually one of the things I wanted, but I’ll also need ability to change saturation, and I don’t want to use an external module for this one, so I think I’ll just let it go.

Ram.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en