11 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> images,
13 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> points, std::size_t pointsPerImage,
14 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> values
16 std::size_t height = shape[0];
17 std::size_t width = shape[1];
18 std::size_t numChannels = shape[2];
19 std::size_t stride = (pointsPerImage == points.size1())? 0: pointsPerImage;
24 auto image = to_matrix(row(images,im), width * height, numChannels);
25 auto v = to_matrix(row(values,im), pointsPerImage, numChannels);
26 for(std::size_t p = 0; p != pointsPerImage; ++p){
27 std::size_t pointIdx = p + im * stride;
28 using std::min;
using std::max;
29 T basex = std::floor(points(pointIdx,1) * width);
30 T t=points(pointIdx, 1) * width - basex;
34 T x[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
36 (std::size_t)min<T>(max<T>(basex-1,0),width-1),
37 (std::size_t)max<T>(min<T>(basex,width-1),0),
38 (std::size_t)min<T>(max<T>(basex+1,0),width-1),
39 (std::size_t) max<T>(min<T>(basex+2,width-1),0)
42 T basey = std::floor(points(pointIdx,0) * height);
43 t=points(pointIdx, 0) * height - basey;
47 T y[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
49 (std::size_t)min<T>(max<T>(basey-1,0),height-1),
50 (std::size_t)max<T>(min<T>(basey,height-1),0),
51 (std::size_t)min<T>(max<T>(basey+1,0),height-1),
52 (std::size_t) max<T>(min<T>(basey+2,height-1),0)
54 for(std::size_t k = 0;k < 4; k++){
55 for(std::size_t l = 0;l < 4; l++){
56 std::size_t index = px[l] + width * py[k];
57 noalias(row(v,p)) += (x[l]*y[k]/36) * row(image,index);
66 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> images,
68 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> points, std::size_t pointsPerImage,
69 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> values,
70 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> valuesdx,
71 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> valuesdy
73 std::size_t height = shape[0];
74 std::size_t width = shape[1];
75 std::size_t numChannels = shape[2];
76 std::size_t stride = (pointsPerImage == points.size1())? 0: pointsPerImage;
82 auto image = to_matrix(row(images,im), width * height, numChannels);
83 auto v = to_matrix(row(values,im), pointsPerImage, numChannels);
84 auto vdx = to_matrix(row(valuesdx,im), pointsPerImage, numChannels);
85 auto vdy = to_matrix(row(valuesdy,im), pointsPerImage, numChannels);
86 for(std::size_t p = 0; p != points.size1(); ++p){
87 std::size_t pointIdx = p + im * stride;
88 using std::min;
using std::max;
89 T basex = std::floor(points(pointIdx,1) * width);
90 T t=points(pointIdx, 1) * width - basex;
94 T x[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
95 T dxdt[4]={-3*t2+6*t-3, 9*t2-12*t, -9*t2+6*t+3, 3*t2};
97 (std::size_t)min<T>(max<T>(basex-1,0),width-1),
98 (std::size_t)max<T>(min<T>(basex,width-1),0),
99 (std::size_t)min<T>(max<T>(basex+1,0),width-1),
100 (std::size_t) max<T>(min<T>(basex+2,width-1),0)
103 T basey = std::floor(points(pointIdx,0) * height);
104 t=points(pointIdx, 0) * height - basey;
108 T y[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
109 T dydt[4]={-3*t2+6*t-3, 9*t2-12*t, -9*t2+6*t+3, 3*t2};
111 (std::size_t)min<T>(max<T>(basey-1,0),height-1),
112 (std::size_t)max<T>(min<T>(basey,height-1),0),
113 (std::size_t)min<T>(max<T>(basey+1,0),height-1),
114 (std::size_t) max<T>(min<T>(basey+2,height-1),0)
117 for(std::size_t k = 0;k < 4; k++){
118 for(std::size_t l = 0;l < 4; l++){
119 std::size_t index = px[l] + width * py[k];
121 T dfdx1 = dxdt[l] * y[k]/36;
122 T dfdx2 = x[l] * dydt[k]/36;
124 noalias(row(v,p)) += vdI * row(image,index);
125 noalias(row(vdx,p)) += dfdx1 * row(image,index);
126 noalias(row(vdy,p)) += dfdx2 * row(image,index);
134 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> imageDerivatives,
136 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> points, std::size_t pointsPerImage,
137 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, blas::cpu_tag> results
139 std::size_t height = shape[0];
140 std::size_t width = shape[1];
141 std::size_t numChannels = shape[2];
142 std::size_t stride = (pointsPerImage == points.size1())? 0: pointsPerImage;
147 auto imageDer = to_matrix(row(imageDerivatives,im), pointsPerImage, numChannels);
148 auto result = to_matrix(row(results,im), width * height, numChannels);
149 for(std::size_t p = 0; p != points.size1(); ++p){
150 std::size_t pointIdx = p + im * stride;
151 using std::min;
using std::max;
152 T basex = std::floor(points(pointIdx,1) * width);
153 T t=points(pointIdx, 1) * width - basex;
157 T x[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
159 (std::size_t)min<T>(max<T>(basex-1,0),width-1),
160 (std::size_t)max<T>(min<T>(basex,width-1),0),
161 (std::size_t)min<T>(max<T>(basex+1,0),width-1),
162 (std::size_t) max<T>(min<T>(basex+2,width-1),0)
165 T basey = std::floor(points(pointIdx,0) * height);
166 t=points(pointIdx, 0) * height - basey;
170 T y[4]={-t3+3*t2-3*t+1, 3*t3-6*t2+4, -3*t3+3*t2+3*t+1, t3};
172 (std::size_t)min<T>(max<T>(basey-1,0),height-1),
173 (std::size_t)max<T>(min<T>(basey,height-1),0),
174 (std::size_t)min<T>(max<T>(basey+1,0),height-1),
175 (std::size_t) max<T>(min<T>(basey+2,height-1),0)
177 for(std::size_t k = 0;k < 4; k++){
178 for(std::size_t l = 0;l < 4; l++){
179 std::size_t index = px[l] + width * py[k];
180 T vdI = x[l]*y[k]/36;
181 noalias(row(result,index)) += vdI * row(imageDer,p);