35 const int height = image->get_height();
39 const float corner_weight = 0.182f;
40 const float center_weight = 1.0f - 2.0f * corner_weight;
48 input_color =
float3(image->get_elem(max(0, x - 1),
min(height - 1, y + 1)));
49 x_partial_derivative += input_color * -corner_weight;
50 input_color =
float3(image->get_elem(max(0, x - 1), y));
51 x_partial_derivative += input_color * -center_weight;
52 input_color =
float3(image->get_elem(max(0, x - 1),
max(0, y - 1)));
53 x_partial_derivative += input_color * -corner_weight;
54 input_color =
float3(image->get_elem(
min(width - 1, x + 1),
min(height - 1, y + 1)));
55 x_partial_derivative += input_color * corner_weight;
56 input_color =
float3(image->get_elem(
min(width - 1, x + 1), y));
57 x_partial_derivative += input_color * center_weight;
58 input_color =
float3(image->get_elem(
min(width - 1, x + 1),
max(0, y - 1)));
59 x_partial_derivative += input_color * corner_weight;
62 input_color =
float3(image->get_elem(max(0, x - 1),
min(height - 1, y + 1)));
63 y_partial_derivative += input_color * corner_weight;
64 input_color =
float3(image->get_elem(x,
min(height - 1, y + 1)));
65 y_partial_derivative += input_color * center_weight;
66 input_color =
float3(image->get_elem(
min(width - 1, x + 1),
min(height - 1, y + 1)));
67 y_partial_derivative += input_color * corner_weight;
68 input_color =
float3(image->get_elem(max(0, x - 1),
max(0, y - 1)));
69 y_partial_derivative += input_color * -corner_weight;
70 input_color =
float3(image->get_elem(x, max(0, y - 1)));
71 y_partial_derivative += input_color * -center_weight;
72 input_color =
float3(image->get_elem(
min(width - 1, x + 1),
max(0, y - 1)));
73 y_partial_derivative += input_color * -corner_weight;
76 float4 structure_tensor =
float4(
dot(x_partial_derivative, x_partial_derivative),
77 dot(x_partial_derivative, y_partial_derivative),
78 dot(x_partial_derivative, y_partial_derivative),
79 dot(y_partial_derivative, y_partial_derivative));