# Revision history [back]

You are on the right track, basically you need an array of pointers:

....
float *angle_ii_row[18]; //probably you'll have 18 images if you copy the angles in 20 bins
for(int k=0;k<18;k++) angle_ii_row[i]=angle_ii[i].ptr(i);
for (int j = 0; j < angle.cols; j++)
{
float angle_temp = angle_row[j];
int which = floor(angle_temp/20);
angle_row_ii[which][j]=angle_temp;
}


You can declare angle_ii_row dynamically also, as a vector<float*> or as a float** (and allocate with new).

A cleaner - but much less efficient - solution would be to create masks using thresholding and copy the images using these masks.

You are on the right track, basically you need an array of pointers:

....
float *angle_ii_row[18]; //probably you'll have 18 images if you copy the angles in 20 bins
for(int k=0;k<18;k++) angle_ii_row[i]=angle_ii[i].ptr(i);
for (int j = 0; j < angle.cols; j++)
j++) //there you had a bug ( j < angle.rows in your code)
{
float angle_temp = angle_row[j];
int which = floor(angle_temp/20);
angle_row_ii[which][j]=angle_temp;
angle_row_ii[which][j]=angle_temp; //directly copy the angle to the corresponding matrix
}


You can declare angle_ii_row dynamically also, as a vector<float*> or as a float** (and allocate with new).

A cleaner - but much less efficient - solution would be to create masks using thresholding and copy the images using these masks.

You are on the right track, basically you need an array of pointers:pointers for the current line of each image:

....
float *angle_ii_row[18]; //probably you'll have 18 images if you copy the angles in 20 bins
for(int k=0;k<18;k++) angle_ii_row[i]=angle_ii[i].ptr(i);
for (int j = 0; j < angle.cols; j++) //there you had a bug ( j < angle.rows in your code)
{
float angle_temp = angle_row[j];
int which = floor(angle_temp/20);
angle_row_ii[which][j]=angle_temp; //directly copy the angle to the corresponding matrix
}


You can declare angle_ii_row dynamically also, as a vector<float*> or as a float** (and allocate with new).

A cleaner - but much less efficient - solution would be to create masks using thresholding and copy the images using these masks.