Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

that shouldn't be dificult. first, you want the angle in degrees, not radians:

cartToPolar(dx,dy,mag,angle, true);

then, it's a double for loop, to get 8x8 patches:

for (int r=0; r<img.rows; r += 8) {
     for (int c=0; c<img.cols; c+=8) {
           Mat patch_angle = angle(Rect(c,r,8,8));
           Mat patch_mag = mag(Rect(c,r,8,8));
     }
}

then, for each patch, you need to make a histogram, an array of counters:

Mat_<float> hist = Mat_<float>::zeros(1,9);

now, iterate over the values in patch_angle and patch_mag, and increase the resp. bin:

int bin = int(patch_angle(r,c) % 180) / 20; //results in a value [0..8]
hist(0, bin) += patch_mag(r,c);

that shouldn't be dificult. first, you want the angle in degrees, not radians:

cartToPolar(dx,dy,mag,angle, true);

then, it's a double for loop, to get 8x8 patches:

for (int r=0; r<img.rows; r += 8) {
     for (int c=0; c<img.cols; c+=8) {
           Mat patch_angle = angle(Rect(c,r,8,8));
           Mat patch_mag = mag(Rect(c,r,8,8));
     }
}

then, for each patch, you need to make a histogram, an array of counters:

Mat_<float> hist = Mat_<float>::zeros(1,9);

now, iterate over the values in patch_angle and patch_mag, and increase the resp. bin:

int bin = int(patch_angle(r,c) (int(patch_angle(r,c) % 180) / 20; //results in a value [0..8]
hist(0, bin) += patch_mag(r,c);

that shouldn't be dificult. first, you want the angle in degrees, not radians:

cartToPolar(dx,dy,mag,angle, true);

then, it's a double for loop, to get 8x8 patches:

for (int r=0; r<img.rows; r += 8) {
     for (int c=0; c<img.cols; c+=8) {
           Mat Mat_<float> patch_angle = angle(Rect(c,r,8,8));
           Mat Mat_<float> patch_mag = mag(Rect(c,r,8,8));
     }
}

then, for each patch, you need to make a histogram, an array of counters:

Mat_<float> hist = Mat_<float>::zeros(1,9);

now, iterate over the values in patch_angle and patch_mag, and increase the resp. bin:

int bin = (int(patch_angle(r,c) % 180) / 20; //results in a value [0..8]
hist(0, bin) += patch_mag(r,c);