| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Hi,
First let me join everybody else in saying that QC is a really great
application, I thoroughly enjoy it!
I'm currently using it to try a "threshold" CoreImage kernel, and two
things baffle me. I've attached my composition, which contains the
kernel in question, applied to an image consisting of a 50% gray
rectangle. My kernel code looks like this:
kernel vec4 threshold(sampler image, float limit)
{
vec4 p = unpremultiply(sample(image, samplerCoord(image)));
float luminance = 0.3*p.r + 0.59*p.g + 0.11*p.b;
float c = (luminance > limit) ? 1.0 : 0.0;
return vec4(c,c,c,1);
}
it first computes the luminance of the sampled pixel p, and if it is
below the limit returns the color black, otherwise it returns the
color white.
The two things which surprise me are:
1. Instead of being black, the pixels below the limit are actually
cyan! The odd thing is that if I change my kernel code to replace the
use of "limit" by a constant in the ternary operator (?:), then the
pixels become black as they should. It this a bug?
(Note: I managed to obtain black pixels by replacing my use of the
ternary operator by a call to the "compare" function, but I'd like to
know why I observe the strange behaviour just described).
2. Since the square in my image is pure 50% gray, it should become
black as soon as the limit reaches 0.5, if I understand things
correctly. But it actually turns black (well, cyan) when the limit
reaches 0.29... Why?
Thanks for your help,
Michel.
Attachment:
ThresholdTest.qtz
Description: Binary data
_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.