| 3287 | # TODO(sjhwang): Gaussian kernel is separable in space. Consider applying |
| 3288 | # 1-by-n and n-by-1 Gaussain filters instead of an n-by-n filter. |
| 3289 | def reducer(x): |
| 3290 | shape = array_ops.shape(x) |
| 3291 | x = array_ops.reshape(x, shape=array_ops.concat([[-1], shape[-3:]], 0)) |
| 3292 | y = nn.depthwise_conv2d(x, kernel, strides=[1, 1, 1, 1], padding='VALID') |
| 3293 | return array_ops.reshape( |
| 3294 | y, array_ops.concat([shape[:-3], array_ops.shape(y)[1:]], 0)) |
| 3295 | |
| 3296 | luminance, cs = _ssim_helper(img1, img2, reducer, max_val, compensation, k1, |
| 3297 | k2) |