I have a 2048x2048 matrix of grayscale image,i want to find some points which value are > 0 ,and store its position into an array of 2 columns and n rows (n is also the number of founded points) Here is my algorithm :

```
int icount;
icount = 0;
for (int i = 0; i < 2048; i++)
{
    for (int j = 0; j < 2048; j++)
    {
        if (iout.at<double>(i, j) > 0)
        {
            icount++;
            temp[icount][1] = i;
            temp[icount][2] = j;
        }
    }
}

```

I have 2 problems :

1. temp is an array which the number of rows is unknown 'cause after each loop the number of rows increases ,so how can i define the temp array ? I need the exact number of rows for another implementation later so i can't give some random number for it.
2. My algorithm above doesn't work,the results is 

```
temp[1][1]=0 , temp[1][2]=0 , temp[2][1]=262 , temp[2][2]=655

```

which is completely wrong,the right one is :

```
temp[1][1]=1779 , temp[1][2]=149 , temp[2][1]=1780 , temp[2][2]=149

```

i got the right result because i implemented it in Matlab, it is 

```
[a,b]=find(iout>0);

```