Android real time image processing FloydSteinberg dithering Java vs C Renderscript
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=bX-ZscRiRQE
The Floyd-Steinberg (FS) algorithm (https://en.wikipedia.org/wiki/Floyd%E...) is a method to reduce the number of colors in an image. • In this demo app the camera preview image (shown in the display's upper left corner) is converted to grayscale (shown below). The FS-algorithm then reduces the 256 gray values to ditherd, soleily black and white pixels, where the ratio of black/white pixels in an area represents the former gray value. • FS-dithering uses a serial algorithm which cannot be easily parallelized. Yet it benefits from Renderscript (using C language) instead of Java, even when running only one serial task • (whilst not using Renderscript´s parallel computing capabilities). • The FS algorithm uses a huge array to store information to each image pixel. To process a single image it takes about (imagewidth*imageheight*10) array accesses. • In Java, arrays are objects which are computationally expensive. Furthermore, Java performs a range check on every array access. This cannot be disabled. • In C, however, arrays are a pointer structures, the access is very fast. Usually there are no range checks. • This app compares a Java with a C implementation of the same (serial) FS-algorithm. Image size in both cases is 640 x 480 pixels. • Results: • Java : 9-10 FramesPerSecond (FPS) • C : 32-34 FramesPerSecond • Overall, the C version outperforms Java by a factor of about 3.5. • Regarding soleily the FS-algorithm, C beats Java by a factor of 6-7. • App created with Basic4Android. • Device : Nexus 7 (2013), JellyBean 4.3, not rooted. • Here is a tutorial how to start real time (live camera) image processing on Android using B4A (Basic4Android). It also includes • basic information how to use the RenderScript framework (parallel data processing on multi-core CPUs). • https://www.b4x.com/android/forum/thr...
#############################
