1
# -*- coding: utf-8 -*-
3
# Copyright © 2009-2010 CEA
5
# Licensed under the terms of the CECILL License
6
# (see guiqwt/__init__.py for details)
8
"""Image filter demo"""
10
SHOW = True # Show test in GUI-based test launcher
12
from scipy.ndimage import gaussian_filter
14
from guiqwt.plot import ImageDialog
15
from guiqwt.builder import make
17
def imshow(x, y, data, filter_area, yreverse=True):
18
win = ImageDialog(edit=False, toolbar=True, wintitle="Image filter demo",
19
options=dict(xlabel="x (cm)", ylabel="y (cm)",
21
image = make.xyimage(x, y, data)
24
xmin, xmax, ymin, ymax = filter_area
25
flt = make.imagefilter(xmin, xmax, ymin, ymax, image,
26
filter=lambda x, y, data: gaussian_filter(data, 5))
27
plot.add_item(flt, z=1)
34
# -- Create QApplication
36
guidata.qapplication()
38
from guiqwt.tests.imagexy import compute_image
39
x, y, data = compute_image()
40
imshow(x, y, data, filter_area=(-3., -1., 0., 2.), yreverse=False)
42
import os.path as osp, numpy as np
43
from guiqwt.io import imagefile_to_array
44
filename = osp.join(osp.dirname(__file__), "brain.png")
45
data = imagefile_to_array(filename)
46
x = np.linspace(0, 30., data.shape[1])
47
y = np.linspace(0, 30., data.shape[0])
48
imshow(x, y, data, filter_area=(10, 20, 5, 15))
50
if __name__ == "__main__":