Example #1
0
def build_items():
    x = np.linspace(-10, 10, 200)
    y = np.sin(np.sin(np.sin(x)))
    filename = osp.join(osp.dirname(__file__), "brain.png")
    items = [ 
              make.curve(x, y, color="b"),
              make.image(filename=filename),
              make.trimage(filename=filename),
              make.maskedimage(filename=filename, colormap='gray',
                               show_mask=True, xdata=[0, 40], ydata=[0, 50]),
              make.label("Relative position <b>outside</b>",
                         (x[0], y[0]), (-10, -10), "BR"),
              make.label("Relative position <i>inside</i>",
                         (x[0], y[0]), (10, 10), "TL"),
              make.label("Absolute position", "R", (0, 0), "R"),
              make.legend("TR"),
              make.rectangle(-3, -0.8, -0.5, -1., "rc1"),
              make.segment(-3, -0.8, -0.5, -1., "se1"),
              make.ellipse(-10, 0.0, 0, 0, "el1"),
              make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"),
              make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"),
              Axes( (0, 0), (1, 0), (0, 1) ),
              PolygonShape(np.array([[150., 330.],
                                     [270., 520.],
                                     [470., 480.],
                                     [520., 360.],
                                     [460., 200.],
                                     [250., 240.]])),
              ]
    return items
Example #2
0
def build_items():
    x = np.linspace(-10, 10, 200)
    y = np.sin(np.sin(np.sin(x)))
    filename = osp.join(osp.dirname(__file__), "brain.png")
    items = [
        make.curve(x, y, color="b"),
        make.image(filename=filename),
        make.trimage(filename=filename),
        make.maskedimage(filename=filename,
                         colormap='gray',
                         show_mask=True,
                         xdata=[0, 40],
                         ydata=[0, 50]),
        make.label("Relative position <b>outside</b>", (x[0], y[0]),
                   (-10, -10), "BR"),
        make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10),
                   "TL"),
        make.label("Absolute position", "R", (0, 0), "R"),
        make.legend("TR"),
        make.rectangle(-3, -0.8, -0.5, -1., "rc1"),
        make.segment(-3, -0.8, -0.5, -1., "se1"),
        make.ellipse(-10, 0.0, 0, 0, "el1"),
        make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"),
        make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"),
        Axes((0, 0), (1, 0), (0, 1)),
        PolygonShape(
            np.array([[150., 330.], [270., 520.], [470., 480.], [520., 360.],
                      [460., 200.], [250., 240.]])),
    ]
    return items
Example #3
0
def create_test_data(fname, func=None):
    array0 = io.imread(osp.join(osp.dirname(__file__), fname),
                       to_grayscale=True)
    if func is not None:
        array0 = func(array0)
    item0 = make.trimage(array0, dx=.1, dy=.1)
    return array0, item0
Example #4
0
def test():
    """Test"""
    N = 500
    data = compute_image(N, N)
    m = data.min()
    M = data.max()
    items = [make.trimage(data, alpha_mask=True, colormap="jet")]
    for type in (np.uint8, np.uint16, np.int8, np.int16):
        info = np.iinfo(type().dtype)
        s = float((info.max - info.min))
        a1 = s * (data - m) / (M - m)
        img = np.array(a1 + info.min, type)
        txtwrite(img, 0, 0, N / 15., str(type))
        items.append(make.trimage(img, colormap="jet"))
    imshow(items, title="Transform test (%dx%d images)" % (N, N))
    return items
Example #5
0
def test():
    """Test"""
    N = 500
    data = compute_image(N, N)
    m = data.min()
    M = data.max()
    items = [make.trimage(data, alpha_mask=True, colormap="jet")]
    for type in (np.uint8, np.uint16, np.int8, np.int16):
        info = np.iinfo(type().dtype)
        s = float((info.max-info.min))
        a1 = s*(data-m)/(M-m)
        img = np.array(a1+info.min, type)
        txtwrite(img, 0, 0, N/15., str(type))
        items.append(make.trimage(img, colormap="jet"))
    imshow(items, title="Transform test (%dx%d images)" % (N, N))
    return items