I have two vectors
cpyH, hist of size 180.
I am performing smoothing
1 2 3 4
|
for(int i = 1; i < hist.size() -1; i++)
{
hist[i] = ( cpyH[i-1] + cpyH[i] + cpyH[i+1] )/3;
}
|
If i = 178 then it would be 178 < 179
so hist[178] = ( cpyH[177] + cpyH[178] + cpyH[179] )/3;
when i = 179 < 179, condition false, then loop should end.
but i get bug, vector is out of range. . Why is that so?
Last edited on
My guess is that your assumption that cpyH and hist are of the same size is not correct.
Both are of same size. I checked by putting break points.
If
so hist[178] = ( cpyH[177] + cpyH[178] + cpyH[179] )/3 |
then
so hist[179] = ( cpyH[178] + cpyH[179] + cpyH[180] )/3 |
Edit: Nevermind, I missed the -1.
Last edited on