Esempio n. 1
0
def test_plugin():
    img = skimage.img_as_float(data.moon())
    viewer = ImageViewer(img)

    def median_filter(img, radius=3):
        return median(img, selem=disk(radius=radius))

    plugin = Plugin(image_filter=median_filter)
    viewer += plugin

    plugin += Slider('radius', 1, 5)

    assert_almost_equal(np.std(viewer.image), 12.556, 3)

    plugin.filter_image()

    assert_almost_equal(np.std(viewer.image), 12.931, 3)

    plugin.show()
    plugin.close()
    plugin.clean_up()
    img, _ = plugin.output()
    assert_equal(img, viewer.image)
Esempio n. 2
0
def viewer():
    image = skimage.data.coins()

    viewer = ImageViewer(image)
    viewer.show()

    viewer += LineProfile(viewer)
    overlay, data = viewer.show()[0]

    #--------------------
    denoise_plugin = Plugin(
        image_filter=skimage.restoration.denoise_tv_bregman)

    denoise_plugin += Slider('weight', 0.01, 0.5, update_on='release')
    denoise_plugin += SaveButtons()

    viewer = ImageViewer(image)
    viewer += denoise_plugin
    denoised = viewer.show()[0][0]
Esempio n. 3
0
def test_plugin():
    img = skimage.img_as_float(data.moon())
    viewer = ImageViewer(img)

    def median_filter(img, radius=3):
        return median(img, selem=disk(radius=radius))

    plugin = Plugin(image_filter=median_filter)
    viewer += plugin

    plugin += Slider('radius', 1, 5)

    assert_almost_equal(np.std(viewer.image), 12.556, 3)

    plugin.filter_image()

    assert_almost_equal(np.std(viewer.image), 12.931, 3)

    plugin.show()
    plugin.close()
    plugin.clean_up()
    img, _ = plugin.output()
    assert_equal(img, viewer.image)
Esempio n. 4
0
    HH = 1. / H
    HH[np.abs(HH) > K] = K

    gg = np.abs(np.fft.ifft2(F * HH))
    gg = gg[:M, :N]
    gg = np.clip(gg, 0, clip)
    gg -= gg.min()
    gg /= gg.max()

    return gg


viewer = ImageViewer(image)

plugin = Plugin(image_filter=apply_inverse_filter)
plugin += Slider('T', 0, 1, value=0.5, value_type='float', update_on='release')
plugin += Slider('a',
                 -0.1,
                 0.1,
                 value=0,
                 value_type='float',
                 update_on='release')
plugin += Slider('b',
                 -0.1,
                 0.1,
                 value=0,
                 value_type='float',
                 update_on='release')
plugin += Slider('K',
                 0,
Esempio n. 5
0
def get_image_viewer():
    image = data.coins()
    viewer = ImageViewer(img_as_float(image))
    viewer += Plugin()
    return viewer
Esempio n. 6
0
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()
Esempio n. 7
0
from skimage import data
from skimage.filter import median_filter

from skimage.viewer import ImageViewer
from skimage.viewer.widgets import Slider, OKCancelButtons, SaveButtons
from skimage.viewer.plugins.base import Plugin

image = data.coins()
viewer = ImageViewer(image)

plugin = Plugin(image_filter=median_filter)
plugin += Slider('radius', 2, 10, value_type='int', update_on='release')
plugin += SaveButtons()
plugin += OKCancelButtons()

viewer += plugin
viewer.show()
Esempio n. 8
0
from skimage.io import imread

from PyQt5 import QtGui


def printf(sigma, value):
    print(value)
    return


# image = data.camera()
image = imread(
    '/Users/zhizhao/PycharmProjects/BOFO/Devlog/test.jpg')  # True means gray
# You can create a UI for a filter just by passing a filter function...
# plugin = OverlayPlugin(image_filter=canny)
plugin = Plugin()
# plugin = OverlayPlugin()
# plugin = LabelPainter()
# plugin = PlotPlugin()
# ... and adding widgets to adjust parameter values.
plugin += Slider(
    'sigma', 0, 5, value_type='int', value=3, callback=printf
)  # name, low=0.0, high=1.0, value=None, value_type='float','int',orientation='horizontal'/'vertical'
# plugin += Button('name',callback=printf) # name, callback
# plugin += ComboBox('Combo', ['123', '312', 'rqr'])  # name, items, ptype='kwarg', callback=None
plugin += Text('text', text='printtext')  # name=None, text=''
# plugin += SaveButtons()
plugin += CheckBox(
    'check', value=False, alignment='left'
)  # name, value=False, alignment='center'/'left'/'right', ptype='kwarg',callback=None
# ... and we can also add buttons to save the overlay:
Esempio n. 9
0
==================================

Demo of a CollectionViewer for viewing collections of images with the
`autolevel` rank filter connected as a plugin.

"""
from skimage import data
from skimage.filter import rank
from skimage.morphology import disk

from skimage.viewer import CollectionViewer
from skimage.viewer.widgets import Slider
from skimage.viewer.plugins.base import Plugin


# Wrap autolevel function to make the disk size a filter argument.
def autolevel(image, disk_size):
    return rank.autolevel(image, disk(disk_size))


img_collection = [data.camera(), data.coins(), data.text()]

plugin = Plugin(image_filter=autolevel)
plugin += Slider("disk_size", 2, 8, value_type="int")
plugin.name = "Autolevel"

viewer = CollectionViewer(img_collection)
viewer += plugin

viewer.show()
==================================

Demo of a CollectionViewer for viewing collections of images with the
`autolevel` rank filter connected as a plugin.

"""
from skimage import data
from skimage.filters import rank
from skimage.morphology import disk

from skimage.viewer import CollectionViewer
from skimage.viewer.widgets import Slider
from skimage.viewer.plugins.base import Plugin


# Wrap autolevel function to make the disk size a filter argument.
def autolevel(image, disk_size):
    return rank.autolevel(image, disk(disk_size))


img_collection = [data.camera(), data.coins(), data.text()]

plugin = Plugin(image_filter=autolevel)
plugin += Slider('disk_size', 2, 8, value_type='int')
plugin.name = "Autolevel"

viewer = CollectionViewer(img_collection)
viewer += plugin

viewer.show()
Esempio n. 11
0
from skimage import data
from skimage.filters import rank
from skimage.filters import threshold_isodata
from skimage.morphology import disk

from skimage.viewer import CollectionViewer
from skimage.viewer.widgets import Slider
from skimage.viewer.plugins.base import Plugin


# Wrap autolevel function to make the disk size a filter argument.
def autolevel(image, nbins):
    return threshold_isodata(image)
    return rank.autolevel(image, nbins)


[row,:, 0]

img_collection = [data.camera(), data.coins(), data.text()]

plugin = Plugin(image_filter=autolevel)
plugin += Slider('nbins', 1, 255, value_type='int')
# plugin.name = "Autolevel"

viewer = CollectionViewer(img_collection)
viewer += plugin

viewer.show()