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 & HelpPrograms › desaturate via tint()
Page Index Toggle Pages: 1
desaturate via tint() (Read 1202 times)
desaturate via tint()
Feb 21st, 2010, 5:23pm
 
i feel like this should be easy enough to figure out, but my brain's not working well today...

i'm using texture() to paint an image to a plane, and i'd like to desaturate the texture in some areas.  tint() seems to be the way to go, but i can't figure out how to desaturate using only tint().

i have r,g,b vals of the texture image at each vertex, so can use them if needed....any suggestions?  thanks!
Re: desaturate via tint()
Reply #1 - Feb 21st, 2010, 6:08pm
 
i dont think you can do that using tint.
quoting dave you can just loop through the pixels[] array, retrieve the color, retrieve the HSB values, modify S (and/or H, B) as desired, recreate an RGB color from your modified values, stuff it back into the pixels array.
Re: desaturate via tint()
Reply #2 - Feb 23rd, 2010, 9:57am
 
mm, but there's no way that would be performant on the scale of an entire texture (mine is 320x240, applied over many polys to a 1200x900 area)...unless i'm missing something?
Re: desaturate via tint()
Reply #3 - Feb 23rd, 2010, 10:03am
 
i dont know what you are doing, but does the saturation needs to fade in / out ? how about saving your textures 2 times. and showing the one you need. or maybe you can also fade when using 2 by laying the b/w one above the colored one and slowy fade it in...
Re: desaturate via tint()
Reply #4 - Feb 23rd, 2010, 10:21am
 
a bit hard to explain, but i'm trying to modify textures in certain areas depending on...things.  basic example -- the camera Capture is applied as a texture to a mesh made with vertex() calls.  areas with more motion/change in the Capture image have more saturated color; areas with less 'fade' into less saturation.

end result is color where motion happens, b/w where things are still.

i might be able to do just what you said, actually -- essentially texture the mesh twice, and use tint() to fade one into the other...however i think that would make the program run almost twice as slow Sad
Re: desaturate via tint()
Reply #5 - Feb 23rd, 2010, 10:29am
 
maybe not texturing it twice and tint it then. maybe greating a pgraphics with your texture, where you already overlay the two images, and then apply them to your vertex mesh... dont know if it is faster thought. but as i dont know how fast it would be, maybe give it a try.

If you have some example code you can upload or send it to me and i will do some testing...
Re: desaturate via tint()
Reply #6 - Feb 23rd, 2010, 10:30am
 
k thx cedric.  wil report back if i can figure anything out.
Re: desaturate via tint()
Reply #7 - Feb 23rd, 2010, 10:36am
 
i edited my post, not sure if you read it.
Re: desaturate via tint()
Reply #8 - Feb 24th, 2010, 1:53am
 
depth wrote on Feb 23rd, 2010, 10:21am:
i think that would make the program run almost twice as slow Sad

Don't think, try! Suppositions about performances can be surprisingly wrong...
Don't forget that stuff done by Processing need some work too, there is no magic. Some operations behind Processing functions are just done by iterating on the pixel array...
Re: desaturate via tint()
Reply #9 - Feb 24th, 2010, 10:12pm
 
thx again for the suggestions....editing the image in an off-screen buffer before applying as a texture might work.  worth a shot.  @PhiLho, yes yes yes, you're right!  just short on time, trying to aim for the most likely possibilities.  will keep experimenting...
Page Index Toggle Pages: 1