diff options
author | Jason Sams <rjsams@android.com> | 2010-02-10 16:58:16 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-02-10 16:58:16 -0800 |
commit | 1d317d1453348d66e41c8b677a27340803139d4b (patch) | |
tree | 810fb0d11ba3ac678cdf38b8c23a7c9f6875c1d4 /libs | |
parent | aa82768b8c6b6e81bb048d2d72b6586eb66b5b5d (diff) | |
download | frameworks_base-1d317d1453348d66e41c8b677a27340803139d4b.zip frameworks_base-1d317d1453348d66e41c8b677a27340803139d4b.tar.gz frameworks_base-1d317d1453348d66e41c8b677a27340803139d4b.tar.bz2 |
Cleanup image processing example script.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/java/ImageProcessing/res/raw/threshold.rs | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/libs/rs/java/ImageProcessing/res/raw/threshold.rs b/libs/rs/java/ImageProcessing/res/raw/threshold.rs index ad4dbd5..72f12355 100644 --- a/libs/rs/java/ImageProcessing/res/raw/threshold.rs +++ b/libs/rs/java/ImageProcessing/res/raw/threshold.rs @@ -5,38 +5,26 @@ struct color_s { char a; }; -void filter(struct color_s *in, struct color_s *out, struct vecF32_3_s *luminanceVector) { - struct vecF32_3_s pixel; - pixel.x = (in->r & 0xFF) / 255.0f; - pixel.y = (in->g & 0xFF) / 255.0f; - pixel.z = (in->b & 0xFF) / 255.0f; - - float luminance = vec3Dot(luminanceVector, &pixel); - luminance = maxf(0.0f, luminance - Params->threshold); - vec3Scale(&pixel, signf(luminance)); - - out->a = in->a; - out->r = pixel.x * 255.0f; - out->g = pixel.y * 255.0f; - out->b = pixel.z * 255.0f; -} - void main() { int t = uptimeMillis(); struct color_s *in = (struct color_s *) InPixel; struct color_s *out = (struct color_s *) OutPixel; - struct vecF32_3_s luminanceVector; - luminanceVector.x = 0.2125f; - luminanceVector.y = 0.7154f; - luminanceVector.z = 0.0721f; - int count = Params->inWidth * Params->inHeight; int i; + float threshold = (Params->threshold * 255.f); for (i = 0; i < count; i++) { - filter(in, out, &luminanceVector); + float luminance = 0.2125f * in->r + + 0.7154f * in->g + + 0.0721f * in->b; + luminance = maxf(0.0f, luminance - threshold); + vec3Scale(&pixel, luminance > 0); + out->a = in->a; + out->r = pixel.x; + out->g = pixel.y; + out->b = pixel.z; in++; out++; |