Function to mimic the 'fspecial' gaussian MATLAB function.
(size, sigma)
| 3205 | |
| 3206 | |
| 3207 | def _fspecial_gauss(size, sigma): |
| 3208 | """Function to mimic the 'fspecial' gaussian MATLAB function.""" |
| 3209 | size = ops.convert_to_tensor(size, dtypes.int32) |
| 3210 | sigma = ops.convert_to_tensor(sigma) |
| 3211 | |
| 3212 | coords = math_ops.cast(math_ops.range(size), sigma.dtype) |
| 3213 | coords -= math_ops.cast(size - 1, sigma.dtype) / 2.0 |
| 3214 | |
| 3215 | g = math_ops.square(coords) |
| 3216 | g *= -0.5 / math_ops.square(sigma) |
| 3217 | |
| 3218 | g = array_ops.reshape(g, shape=[1, -1]) + array_ops.reshape(g, shape=[-1, 1]) |
| 3219 | g = array_ops.reshape(g, shape=[1, -1]) # For tf.nn.softmax(). |
| 3220 | g = nn_ops.softmax(g) |
| 3221 | return array_ops.reshape(g, shape=[size, size, 1, 1]) |
| 3222 | |
| 3223 | |
| 3224 | def _ssim_per_channel(img1, |