add histogram of bin 170 to 180 in histogrm of bin 0 to 10

I have histogram in bins range 0 to 180.
I want to add histogram of bin 170 to 180 to histogram of bins 0 to 10.

For that , i am doing like this

for(int i = 0, j = 1 ; i < 10, j < 17 ; i++ , j=+2)
{
hist[i] = hist[i] +hist[i + (hueBins - j)];
}

but at i = 2, j is not changed . j should be 177 when i =2 .
Is it not ?

Any one can please help me to make it workable .
thansk
http://www.cplusplus.com/doc/tutorial/control/

read the part about "for loop"
Lots of ways to do this.
Since you refer to bins 0 to 180, the array must have at least 181 elements.
int hist[181];

1
2
3
4
    for (int i=0; i<11; i++)
    {
        hist[i] += hist[180-i];
    }


or
1
2
3
4
    for (int i=0, j=180; i<11; i++, j--)
    {
        hist[i] += hist[j];
    }
Last edited on
Topic archived. No new replies allowed.