Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: CI threshold problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CI threshold problem



Off the top of my head (i.e. untested, but it should work ;) :

vec4 newpix = sample(image, samplerCoord(image));       
return (newpix.r + newpix.g + newpix.b)/3.0 > threshold?
    (newpix - threshold) / (1.0 - threshold) :
    vec4(0.0,0.0,0.0,1.0);

(It first tests if r+g+b/3 is greater than the threshold. If it is, it reduces the value by the threshold value and then scales to 1.0, if not it returns black.)

Chris


2008/10/16 Jesse Lucas <email@hidden>
Hi List,

I'm trying to create a kind of threshold effect, but I'm very new to CI coding. Here's what I'm trying to achieve:

-I need to change all pixels under a certain brightness value to black.
- And remap the brightness of the remain pixels to a 0 to 1 range (so I get contrast even on high threshold values).

- It doesn't matter if the resulting output is grayscale, I don't need the color information.

It is definitely not working right now so I need your help :)

Here's the code I've got for now (and I've attached the simple patch)
:

kernel vec4 threshhold(sampler image, float threshold)
{
       vec4 newpix = sample(image, samplerCoord(image));      
       vec4 newpix = (newpix - threshold) / (1.0-threshold*1.1);
       newpix.a = 1.0;
       return vec4 (newpix);
}





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >CI threshold problem (From: Jesse Lucas <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.