def test_save_buttons(): viewer = get_image_viewer() sv = SaveButtons() viewer.plugins[0] += sv import tempfile fid, filename = tempfile.mkstemp(suffix='.png') os.close(fid) timer = QtCore.QTimer() timer.singleShot(100, QtGui.QApplication.quit) # exercise the button clicks sv.save_stack.click() sv.save_file.click() # call the save functions directly sv.save_to_stack() with expected_warnings(['precision loss']): sv.save_to_file(filename) img = data.imread(filename) with expected_warnings(['precision loss']): assert_almost_equal(img, img_as_uint(viewer.image)) img = io.pop() assert_almost_equal(img, viewer.image) os.remove(filename)
def test_save_buttons(): viewer = get_image_viewer() sv = SaveButtons() viewer.plugins[0] += sv import tempfile _, filename = tempfile.mkstemp(suffix='.png') os.remove(filename) timer = QtCore.QTimer() timer.singleShot(100, lambda: QtGui.QApplication.quit()) sv.save_to_stack() sv.save_to_file(filename) img = img_as_float(data.imread(filename)) assert_almost_equal(img, viewer.image) img = io.pop() assert_almost_equal(img, viewer.image)
def test_save_buttons(): viewer = get_image_viewer() sv = SaveButtons() viewer.plugins[0] += sv import tempfile fid, filename = tempfile.mkstemp(suffix='.png') os.close(fid) timer = QtCore.QTimer() timer.singleShot(100, QtWidgets.QApplication.quit) # exercise the button clicks sv.save_stack.click() sv.save_file.click() # call the save functions directly sv.save_to_stack() with expected_warnings(['precision loss']): sv.save_to_file(filename) img = data.imread(filename) with expected_warnings(['precision loss']): assert_almost_equal(img, img_as_uint(viewer.image)) img = io.pop() assert_almost_equal(img, viewer.image) os.remove(filename)
from skimage import data from skimage.restoration import denoise_tv_chambolle from skimage.util import img_as_float from numpy import random, clip from skimage.viewer import ImageViewer from skimage.viewer.widgets import (Slider, CheckBox, OKCancelButtons, SaveButtons) from skimage.viewer.plugins.base import Plugin image = img_as_float(data.chelsea()) sigma = 30 / 255. image = image + random.normal(loc=0, scale=sigma, size=image.shape) image = clip(image, 0, 1) viewer = ImageViewer(image) plugin = Plugin(image_filter=denoise_tv_chambolle) plugin += Slider('weight', 0.01, 5, value=0.3, value_type='float') plugin += Slider('n_iter_max', 1, 100, value=20, value_type='int') plugin += CheckBox('multichannel', value=True) plugin += SaveButtons() plugin += OKCancelButtons() viewer += plugin viewer.show()
def __init__(self, maxdist=10, **kwargs): super(Crop, self).__init__(**kwargs) self.maxdist = maxdist self.add_widget(SaveButtons()) print(self.help())