views:

68

answers:

1

Ok so lets say I have an int[][] arrayA and an int[][] arrayB. At any given coordinate in this array lies an RGB value. What I want to do is merge the RGB values from arrayA and array2 into a new array, newArray, using a weighted average method.

So what I'm doing is extracting the red, green, and blue values from each RGB value like this:

        curColA=RGB //suppose RGB is just the RGB in any given point

        int curRedA = (curCol >> 16) & 0xFF;

        int curGreenA = (curCol >> 8) & 0xFF;

        int curBlueA= curCol & 0xFF;

I do the same for arrayB, and now I want to merge them. Here's where I'm having trouble. Do I just do newRed=(curRedA+curRedB)/2 or is there some other way to do this?

arrayA values:  { { 0, 0x44, 0x5500, 0x660000 } };
arrayB values:  { { 2, 4, 6, 8 } };
newArray expected values: { 0, 0x44, 6, 0x660000 } };
+1  A: 

A weighted average is usually done something like:

newRed = (curRedA * redWeight + curRedB * (1 - redWeight));

...where redWeight is in the range [0, 1], and represents the weight (or bias) towards red values in the 'A' array. It also represents the inverse of the bias toward the red values in the 'B' array.

sje397
And whats redWeight equal to?
fprime
@fprime - I'm not sure. The idea of using a weighted average doesn't seem to fit your expected output, the way I understand it.
sje397