def roundtrip(self, dtype, x, scaling=1): f = NamedTemporaryFile(suffix='.png') imsave(f.name, x) f.seek(0) y = imread(f.name) assert_array_almost_equal((x * scaling).astype(np.int32), y)
def crop(event): if event.key != 'c': return fn = canvas.name + "_crop.png" h, w = canvas.patch_size sio.imsave(fn, canvas.img[canvas.y:canvas.y + h, canvas.x:canvas.x + w]) print "Written cropped image to %s." % fn
def roundtrip(self, dtype, x, scaling=1): f = NamedTemporaryFile(suffix='.png') fname = f.name f.close() imsave(fname, x) y = imread(fname) assert_array_almost_equal((x * scaling).astype(np.int32), y)
def test_save(self): io.imsave("test.png", [1, 2, 3], plugin="test")
def save_to_file(self): from scikits.image import io filename = str(QtGui.QFileDialog.getSaveFileName()) if len(filename) == 0: return io.imsave(filename, self.arr)
def test_save(self): io.imsave('test.png', [1, 2, 3], plugin='test')
# Source coordinates sc = np.array(plt.ginput(n=4)) screen_coords = [(0, 0), (1023, 0), (1023, 767), (0, 767)] # Homography: source to camera H_SC = estimate_homography(screen_coords, sc) tc = np.array(plt.ginput(n=4)) print tc tc_in_screen = \ np.dot(np.linalg.inv(H_SC), np.hstack((tc, np.ones((4,1)))).T).T tc_in_screen /= tc_in_screen[:, 2, np.newaxis] # Screen to screen homography H_SS = estimate_homography(screen_coords, tc_in_screen) grid = sio.imread('fatgrid.jpg') grid_warp = tf.homography(grid, H_SS, output_shape=grid.shape, order=2) np.save('/tmp/H_SS.npy', H_SS) sio.imsave('/tmp/grid_warp.png', grid_warp)
from scikits.image import io, transform s = 0.7 img = io.imread('scikits_image_logo.png') h, w, c = img.shape print "\nScaling down logo by %.1fx..." % s img = transform.homography(img, [[s, 0, 0], [0, s, 0], [0, 0, 1]], output_shape=(int(h*s), int(w*s), 4), order=3) io.imsave('scikits_image_logo_small.png', img)