import numpy, glumpy window = glumpy.Window(512, 512) Z = numpy.asarray(Image.open('lena.png')) n = 12 L = glumpy.Image(Z, interpolation='bicubic') N = glumpy.Image(numpy.ones((n, n, 3), dtype=numpy.uint8), interpolation='nearest') BL = glumpy.Image(numpy.zeros((n, n, 3), dtype=numpy.uint8), interpolation='bilinear') BC = glumpy.Image(numpy.zeros((n, n, 3), dtype=numpy.uint8), interpolation='bicubic') z = 512 / (3.0 * n) shape, items = glumpy.layout([[L, '-', '-'], [(N, z), (BL, z), (BC, z)]], padding=0, border=0) window.set_size(int(shape[0] * 600), int(shape[1] * 600)) @window.event def on_mouse_motion(x, y, dx, dy): global L, N, BN, BC, n i, x0, y0, w, h = items[0] x0, y0 = x0 * 600 * shape[0], y0 * 600 * shape[1] w, h = w * 600 * shape[0] - 1, h * 600 * shape[1] + 1 x = min(max(x - x0, 0), w) / float(w) * 512 y = (1 - min(max(y - y0, 0), h) / float(h)) * 512 x = max(min(x, 512 - n // 2), n // 2) y = max(min(y, 512 - n // 2), n // 2)
# Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. # ----------------------------------------------------------------------------- from PIL import Image import numpy, glumpy window = glumpy.Window(512, 512) Z = numpy.asarray(Image.open("lena.png")) n = 12 L = glumpy.Image(Z, interpolation="bicubic") N = glumpy.Image(numpy.ones((n, n, 3), dtype=numpy.uint8), interpolation="nearest") BL = glumpy.Image(numpy.zeros((n, n, 3), dtype=numpy.uint8), interpolation="bilinear") BC = glumpy.Image(numpy.zeros((n, n, 3), dtype=numpy.uint8), interpolation="bicubic") z = 512 / (3.0 * n) shape, items = glumpy.layout([[L, "-", "-"], [(N, z), (BL, z), (BC, z)]], padding=0, border=0) window.set_size(int(shape[0] * 600), int(shape[1] * 600)) @window.event def on_mouse_motion(x, y, dx, dy): global L, N, BN, BC, n i, x0, y0, w, h = items[0] x0, y0 = x0 * 600 * shape[0], y0 * 600 * shape[1] w, h = w * 600 * shape[0] - 1, h * 600 * shape[1] + 1 x = min(max(x - x0, 0), w) / float(w) * 512 y = (1 - min(max(y - y0, 0), h) / float(h)) * 512 x = max(min(x, 512 - n // 2), n // 2) y = max(min(y, 512 - n // 2), n // 2) N.data[...] = L.data[y - n // 2 : y + n // 2, x - n // 2 : x + n // 2]
# Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- import numpy, glumpy import OpenGL.GL as gl window = glumpy.Window(512, 512) A = glumpy.Image(numpy.random.random((100, 100)).astype(numpy.float32), cmap=glumpy.colormap.Grey) B = glumpy.Image(numpy.random.random((50, 50)).astype(numpy.float32), cmap=glumpy.colormap.Grey) C = glumpy.Image(numpy.random.random((30, 30)).astype(numpy.float32), cmap=glumpy.colormap.Grey) shape, items = glumpy.layout([[(A, 1.05), '-'], [(C, 5 / 3.), B]], padding=5, border=5) window.set_size(int(shape[0] * 600), int(shape[1] * 600)) @window.event def on_draw(): window.clear() gl.glColor4f(1, 1, 1, 1) for item in items: Z, x, y, w, h = item x, y = x * 600 * shape[0], y * 600 * shape[1] w, h = w * 600 * shape[0] - 1, h * 600 * shape[1] + 1 Z.blit(x, y, w, h)
# # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- import numpy, glumpy import OpenGL.GL as gl window = glumpy.Window(512, 512) A = glumpy.Image(numpy.random.random((100,100)).astype(numpy.float32), cmap=glumpy.colormap.Grey) B = glumpy.Image(numpy.random.random((50,50)).astype(numpy.float32), cmap=glumpy.colormap.Grey) C = glumpy.Image(numpy.random.random((30,30)).astype(numpy.float32), cmap=glumpy.colormap.Grey) shape, items = glumpy.layout([ [(A,1.05), '-'], [(C,5/3.), B ] ], padding=5, border=5) window.set_size(int(shape[0]*600), int(shape[1]*600)) @window.event def on_draw(): window.clear() gl.glColor4f(1,1,1,1) for item in items: Z,x,y,w,h = item x,y = x*600*shape[0], y*600*shape[1] w,h = w*600*shape[0]-1, h*600*shape[1]+1 Z.blit(x,y,w,h) window.mainloop()