Esempio n. 1
0
void Surf::gradient(float x, float y, float *f, float *dx, float *dy)
{
	x = x / step;
	y = y / step;
	int ixp = (int)floor(x);
	int iyp = (int)floor(y);
	float wx1 = x - ixp, wx0 = 1.0f - wx1;
	float wy1 = y - iyp, wy0 = 1.0f - wy1;
	float w00 = wx0 * wy0;
	float w01 = wx0 * wy1;
	float w10 = wx1 * wy0;
	float w11 = wx1 * wy1;
	float *f00 = cell_hist(ixp * step, iyp * step);
	float *f01 = cell_hist(ixp * step, (iyp + 1) * step);
	float *f10 = cell_hist((ixp + 1) * step, iyp * step);
	float *f11 = cell_hist((ixp + 1) * step, (iyp + 1) * step);
	wx0 /= step;
	wy0 /= step;
	wx1 /= step;
	wy1 /= step;
	for (int i = 0; i < L; ++i) {
		f[i] = f00[i] * w00 + f01[i] * w01 + f10[i] * w10 + f11[i] * w11;
		dx[i] = (f10[i] - f00[i]) * wy0 + (f11[i] - f01[i]) * wy1;
		dy[i] = (f01[i] - f00[i]) * wx0 + (f11[i] - f10[i]) * wx1;
	}
}
Esempio n. 2
0
void Surf::gradient(float x, float y, float *f, float *dx, float *dy)
{
	//gradient based on the bilinear interpolation
	x = x / step;
	y = y / step;
	int ixp = (int)floor(x);
	int iyp = (int)floor(y);
	float wx1 = x - ixp, wx0 = 1.0f - wx1;
	float wy1 = y - iyp, wy0 = 1.0f - wy1;
	float w00 = wx0 * wy0;
	float w01 = wx0 * wy1;
	float w10 = wx1 * wy0;
	float w11 = wx1 * wy1;
	wx0 /= step;
	wy0 /= step;
	wx1 /= step;
	wy1 /= step;
	ixp *= step;
	iyp *= step;
	float *f00 = cell_hist(ixp, iyp);
	float *f01 = cell_hist(ixp, iyp + step);
	float *f10 = cell_hist(ixp + step, iyp);
	float *f11 = cell_hist(ixp + step, iyp + step);
	for (int i = 0; i < 8; ++i) {
		f[i] = f00[i] * w00 + f01[i] * w01 + f10[i] * w10 + f11[i] * w11;
		dx[i] = (f10[i] - f00[i]) * wy0 + (f11[i] - f01[i]) * wy1;
		dy[i] = (f01[i] - f00[i]) * wx0 + (f11[i] - f10[i]) * wx1;
	}
}
Esempio n. 3
0
void Surf::descriptor(float x, float y, float *f)
{
	x = x / step;
	y = y / step;
	int ixp = (int)floor(x);
	int iyp = (int)floor(y);
	float wx1 = x - ixp, wx0 = 1.0f - wx1;
	float wy1 = y - iyp, wy0 = 1.0f - wy1;
	float w00 = wx0 * wy0;
	float w01 = wx0 * wy1;
	float w10 = wx1 * wy0;
	float w11 = wx1 * wy1;
	float *f00 = cell_hist(ixp * step, iyp * step);
	float *f01 = cell_hist(ixp * step, (iyp + 1) * step);
	float *f10 = cell_hist((ixp + 1) * step, iyp * step);
	float *f11 = cell_hist((ixp + 1) * step, (iyp + 1) * step);
	for (int i = 0; i < L; ++i)
		f[i] = f00[i] * w00 + f01[i] * w01 + f10[i] * w10 + f11[i] * w11;
}
Esempio n. 4
0
void Surf::descriptor(float x, float y, float *f)
{
	//bilinear interpolation
	x = x / step;
	y = y / step;
	int ixp = (int)floor(x);
	int iyp = (int)floor(y);
	float wx1 = x - ixp, wx0 = 1.0f - wx1;
	float wy1 = y - iyp, wy0 = 1.0f - wy1;
	float w00 = wx0 * wy0;
	float w01 = wx0 * wy1;
	float w10 = wx1 * wy0;
	float w11 = wx1 * wy1;
	ixp *= step;
	iyp *= step;
	float *f00 = cell_hist(ixp, iyp);
	float *f01 = cell_hist(ixp, iyp + step);
	float *f10 = cell_hist(ixp + step, iyp);
	float *f11 = cell_hist(ixp + step, iyp + step);
	for (int i = 0; i < 8; ++i)
		f[i] = f00[i] * w00 + f01[i] * w01 + f10[i] * w10 + f11[i] * w11;
}