Java: taking average of 16 image byte arrays in Android
<p>my android app is taking several images in a row. Every time I take a picture using takePicture() I convert the byte array into a PNG using BitmapFactory. My final goal is to get the average of 16 images. To speed up the process I was thinking of averaging the byte arrays before creating a PNG instead of creating 16 images and then trying to average them. Any suggestions on how to do this?</p>

<p>Simply, I want to do something like this: </p>

<pre><code>imgByteArray1 = [1,2,3,4]
imgByteArray2 = [4,3,2,1]

totalImgByteArray = imgByteArray1 + imgByteArray2
//totalImgByteArray will equal [5,5,5,5]
aveImgByteArray = totalImgByteArray / 2
//aveImgByteArray will equal [2.5,2.5,2.5,2.5]
</code></pre>

<p>Then from aveImgByteArray I can create a PNG file.</p>

<p>I'm using the same code as in <a href="http://stackoverflow.com/q/5545952/654781">Android 2.3.1 Camera takePicture() Multiple images with one button click</a> to capture the images.
First I'm collecting the byte arrays into one byte array:</p>

<pre><code>for(int i=0; i &lt; data.length ; i++)
    totalImgData[i] = (byte) (totalImgData[i] + data[i]);
</code></pre>

<p>Then I'm averaging across the array after I've collected for 16 images:</p>

<pre><code>for (int j=0; j &lt; totalImgData.length; j++)
    aveImgData[j] = (byte) (totalImgData[j] / 16);
</code></pre>

<p>This doesn't work... Sorry I'm a bit new to Android with Java.</p>
