We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › desaturating an image
Page Index Toggle Pages: 1
desaturating an image (Read 680 times)
desaturating an image
Jul 28th, 2009, 9:42am
 
hi all,
i have a color image which i would like to fade to gray and back to color. my first thought was to use the tint() function in hsb color mode, but any transformation where the saturation value is 0 has no impact. then i found PImage.filter(GRAY) but this cannot be animated (and it is awfully slow).

i would like to avoid using two seperate images and fade them into each other.

any suggestions?
Re: desaturating an image
Reply #1 - Jul 28th, 2009, 10:40am
 
I've not tried this, but from what I've read in the past it sounds like you might want to use bitwise operators on the pixels[] array.  In fact a search on "bitwise operators desaturate" turned up this.  It's PHP - but I'm sure the principles remain the same - and it doesn't animate; but I guess you could calculate the greyscale target value and then iterate the colour values towards it somehow...
Re: desaturating an image
Reply #2 - Jul 28th, 2009, 11:02am
 
maybe you find something in here : http://www.davebollinger.com/works/imageadjuster/
Re: desaturating an image
Reply #3 - Jul 31st, 2009, 2:12pm
 
thanks to both of you!
the approach shown in php seams to be working, but as you said it doesn't really support animation. and the imageadjuster unfortunately doesn't seam to work with saturation.
so it probably really would be best to create two versions of the image first and then blend them into each other.
anyway, because of some hardware-issues i had to switch the whole projects over to openframeworks/c++, but i'll post it here if i come across a better solution.
Page Index Toggle Pages: 1