diff options
Diffstat (limited to 'libs/rs/java/ImageProcessing/res')
| -rw-r--r-- | libs/rs/java/ImageProcessing/res/drawable-hdpi/data.jpg | bin | 0 -> 76367 bytes | |||
| -rw-r--r-- | libs/rs/java/ImageProcessing/res/layout/main.xml | 38 | ||||
| -rw-r--r-- | libs/rs/java/ImageProcessing/res/raw/threshold.rs | 44 |
3 files changed, 82 insertions, 0 deletions
diff --git a/libs/rs/java/ImageProcessing/res/drawable-hdpi/data.jpg b/libs/rs/java/ImageProcessing/res/drawable-hdpi/data.jpg Binary files differnew file mode 100644 index 0000000..81a87b1 --- /dev/null +++ b/libs/rs/java/ImageProcessing/res/drawable-hdpi/data.jpg diff --git a/libs/rs/java/ImageProcessing/res/layout/main.xml b/libs/rs/java/ImageProcessing/res/layout/main.xml new file mode 100644 index 0000000..0872cf2a --- /dev/null +++ b/libs/rs/java/ImageProcessing/res/layout/main.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + + <SurfaceView + android:id="@+id/surface" + android:layout_width="1dip" + android:layout_height="1dip" /> + + <ImageView + android:id="@+id/display" + android:layout_width="320dip" + android:layout_height="266dip" /> + + <SeekBar + android:id="@+id/threshold" + android:layout_marginBottom="10dip" + android:layout_marginLeft="10dip" + android:layout_marginRight="10dip" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" /> + +</merge>
\ No newline at end of file diff --git a/libs/rs/java/ImageProcessing/res/raw/threshold.rs b/libs/rs/java/ImageProcessing/res/raw/threshold.rs new file mode 100644 index 0000000..dec5587 --- /dev/null +++ b/libs/rs/java/ImageProcessing/res/raw/threshold.rs @@ -0,0 +1,44 @@ +struct color_s { + char b; + char g; + char r; + char a; +}; + +void filter(struct color_s *in, struct color_s *out, struct vec3_s *luminanceVector) { + struct vec3_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() { + struct color_s *in = (struct color_s *) InPixel; + struct color_s *out = (struct color_s *) OutPixel; + + struct vec3_s luminanceVector; + luminanceVector.x = 0.2125f; + luminanceVector.y = 0.7154f; + luminanceVector.z = 0.0721f; + + int count = Params->inWidth * Params->inHeight; + int i; + + for (i = 0; i < count; i++) { + filter(in, out, &luminanceVector); + + in++; + out++; + } + + sendToClient(&count, 1, 4, 0); +} |
