"""Demonstrate variance maps.""" import os.path import matplotlib.pyplot as plt import supreme import supreme.io from supreme.config import data_path from supreme.ext import variance_map fn = 'toystory/toystory001.png' x = supreme.io.imread(os.path.join(data_path, fn), flatten=True) plt.subplot(121) plt.imshow(x, cmap=plt.cm.gray) plt.xlabel('Input image') plt.subplot(122) vm = variance_map(x, shape=(20, 20)) vm /= vm.max() plt.imshow(vm) plt.xlabel('Variance map') plt.show()
def test_variance_map(self): x = np.arange(12).reshape((3, 4)) vm = ext.variance_map(x) assert_almost_equal(vm[1, 1], np.var(x[:3,:3])) assert_almost_equal(vm[1, 2], np.var(x[:3,1:4]))
def test_empty(self): ext.variance_map(np.empty((1, 1, 1)))
def test_variance_map(self): x = np.arange(12).reshape((3, 4)) vm = ext.variance_map(x) assert_almost_equal(vm[1, 1], np.var(x[:3, :3])) assert_almost_equal(vm[1, 2], np.var(x[:3, 1:4]))
"""Demonstrate variance maps.""" import os.path import matplotlib.pyplot as plt import supreme import supreme.io from supreme.config import data_path from supreme.ext import variance_map fn = 'toystory/toystory001.png' x = supreme.io.imread(os.path.join(data_path,fn),flatten=True) plt.subplot(121) plt.imshow(x,cmap=plt.cm.gray) plt.xlabel('Input image') plt.subplot(122) vm = variance_map(x,shape=(20,20)) vm /= vm.max() plt.imshow(vm) plt.xlabel('Variance map') plt.show()