Ejemplo n.º 1
0
def test_check_box():
    viewer = get_image_viewer()
    cb = CheckBox('hello', value=True, alignment='left')
    viewer.plugins[0] += cb

    assert_equal(cb.val, True)
    cb.val = False
    assert_equal(cb.val, False)
    cb.val = 1
    assert_equal(cb.val, True)
    cb.val = 0
    assert_equal(cb.val, False)
Ejemplo n.º 2
0
def test_check_box():
    viewer = get_image_viewer()
    cb = CheckBox('hello', value=True, alignment='left')
    viewer.plugins[0] += cb

    assert_equal(cb.val, True)
    cb.val = False
    assert_equal(cb.val, False)
    cb.val = 1
    assert_equal(cb.val, True)
    cb.val = 0
    assert_equal(cb.val, False)
    def __init__(self, search_pattern):
        bottom_px = 60

        self.bottom_px = bottom_px

        plugin = Plugin(image_filter=self.image_filter, dock="right")

        self.setup_names = ['Bottom']

        self.show_orig = CheckBox('show_orig', value=False, alignment='left')

        plugin += self.show_orig
        plugin += ComboBox('setup', self.setup_names)
        plugin += Slider('bottom_px',
                         0,
                         500,
                         value=self.bottom_px,
                         value_type='int')
        plugin += Button("Print", callback=self.on_print_click)

        fnames = [path for path in glob.iglob(search_pattern, recursive=True)]
        images, gray_images = read_images(fnames)

        self.viewer = CollectionViewer(images)
        self.viewer += plugin
Ejemplo n.º 4
0
    def __init__(self, search_pattern):
        blur_kernel_size = 1

        cal_fnames = [
            path for path in glob.iglob('camera_cal/*.jpg', recursive=True)
        ]
        cal_images, cal_gray_images = read_images(cal_fnames)
        self.objpoints, self.imgpoints, _ = get_chessboard_corners(
            cal_images, cal_gray_images)

        self.blur_kernel_size = blur_kernel_size
        self.top_left_x = top_left_x
        self.top_left_y = top_left_y
        self.top_right_x = top_right_x
        self.top_right_y = top_right_y
        self.bottom_right_x = bottom_right_x
        self.bottom_right_y = bottom_right_y
        self.bottom_left_x = bottom_left_x
        self.bottom_left_y = bottom_left_y

        plugin = Plugin(image_filter=self.image_filter, dock="right")

        self.setup_names = [
            'ROI poly', "ROI Transformation", 'ROI Transformed',
            "Final Transformation poly", 'Final Transformation',
            'Final Transformed'
        ]

        self.show_orig = CheckBox('show_orig', value=False, alignment='left')

        plugin += self.show_orig
        plugin += ComboBox('setup', self.setup_names)
        plugin += Slider('blur_kernel_size',
                         0,
                         31,
                         value=self.blur_kernel_size,
                         value_type='int')
        plugin += Slider('top_left_x', 0, 1, value=self.top_left_x)
        plugin += Slider('top_left_y', 0, 1, value=self.top_left_y)
        plugin += Slider('top_right_x', 0, 1, value=self.top_right_x)
        plugin += Slider('top_right_y', 0, 1, value=self.top_right_y)
        plugin += Slider('bottom_right_x', 0, 1, value=self.bottom_right_x)
        plugin += Slider('bottom_right_y', 0, 1, value=self.bottom_right_y)
        plugin += Slider('bottom_left_x', 0, 1, value=self.bottom_left_x)
        plugin += Slider('bottom_left_y', 0, 1, value=self.bottom_left_y)
        plugin += Button("Print", callback=self.on_print_click)

        fnames = [path for path in glob.iglob(search_pattern, recursive=True)]
        images, gray_images = read_images(fnames)

        self.viewer = CollectionViewer(images)
        self.viewer += plugin
Ejemplo n.º 5
0
    def __init__(self, search_pattern):
        self.plugin = Plugin(image_filter=self.image_filter, dock="right")

        self.setup_names = ['Yellow', 'White', 'Yellow / White']
        self.color_spaces = ['LAB', 'HSV', 'HLS', 'LUV']

        self.show_orig = CheckBox('show_orig', value=False, alignment='left')

        self.plugin += self.show_orig
        self.setup = ComboBox('setup', self.setup_names)
        self.color_space = ComboBox('color_space', self.color_spaces)
        self.sensity_range = Slider('sensity_range',
                                    10,
                                    100,
                                    value=sensity_range,
                                    value_type='int')
        self.lower_yellow_1 = Slider('lower_yellow_1',
                                     0,
                                     255,
                                     value=lower_yellow_1,
                                     value_type='int')
        self.lower_yellow_2 = Slider('lower_yellow_2',
                                     0,
                                     255,
                                     value=lower_yellow_2,
                                     value_type='int')
        self.lower_yellow_3 = Slider('lower_yellow_3',
                                     0,
                                     255,
                                     value=lower_yellow_3,
                                     value_type='int')
        self.upper_yellow_1 = Slider('upper_yellow_1',
                                     0,
                                     255,
                                     value=upper_yellow_1,
                                     value_type='int')
        self.upper_yellow_2 = Slider('upper_yellow_2',
                                     0,
                                     255,
                                     value=upper_yellow_2,
                                     value_type='int')
        self.upper_yellow_3 = Slider('upper_yellow_3',
                                     0,
                                     255,
                                     value=upper_yellow_3,
                                     value_type='int')

        self.lower_white_1 = Slider('lower_white_1',
                                    0,
                                    255,
                                    value=lower_white_1,
                                    value_type='int')
        self.lower_white_2 = Slider('lower_white_2',
                                    0,
                                    255,
                                    value=lower_white_2,
                                    value_type='int')
        self.lower_white_3 = Slider('lower_white_3',
                                    0,
                                    255,
                                    value=lower_white_3,
                                    value_type='int')
        self.upper_white_1 = Slider('upper_white_1',
                                    0,
                                    255,
                                    value=upper_white_1,
                                    value_type='int')
        self.upper_white_2 = Slider('upper_white_2',
                                    0,
                                    255,
                                    value=upper_white_2,
                                    value_type='int')
        self.upper_white_3 = Slider('upper_white_3',
                                    0,
                                    255,
                                    value=upper_white_3,
                                    value_type='int')

        self.plugin += self.setup
        self.plugin += self.color_space
        # self.plugin += self.sensity_range
        self.plugin += self.lower_yellow_1
        self.plugin += self.lower_yellow_2
        self.plugin += self.lower_yellow_3
        self.plugin += self.upper_yellow_1
        self.plugin += self.upper_yellow_2
        self.plugin += self.upper_yellow_3

        self.plugin += self.lower_white_1
        self.plugin += self.lower_white_2
        self.plugin += self.lower_white_3
        self.plugin += self.upper_white_1
        self.plugin += self.upper_white_2
        self.plugin += self.upper_white_3

        fnames = [path for path in glob.iglob(search_pattern, recursive=True)]
        images, gray_images = read_images(fnames)

        self.viewer = CollectionViewer(images)
        self.viewer.connect_event('button_press_event', self.on_filter_color)
        self.viewer.connect_event('key_press_event', self.on_press)
        self.viewer += self.plugin
Ejemplo 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()
    def __init__(self, search_pattern):
        plugin = Plugin(image_filter=self.image_filter, dock="right")

        self.setup_names = [
            'Sobel Thresh X', 'Sobel Thresh Y', 'Sobel Thresh X / Y',
            'Magnitude Thresh', 'Gradient Direction',
            'Magnitude / Gradient Direction Thresh', "2 & 2", "2 | 2"
        ]

        self.show_orig = CheckBox('show_orig', value=False, alignment='left')

        plugin += self.show_orig
        plugin += ComboBox('setup', self.setup_names)
        plugin += Slider('grad_ksize',
                         0,
                         31,
                         value=grad_ksize,
                         value_type='int')
        plugin += Slider('grad_thresh_low',
                         0,
                         255,
                         value=grad_thresh_low,
                         value_type='int')
        plugin += Slider('grad_thresh_high',
                         0,
                         255,
                         value=grad_thresh_high,
                         value_type='int')
        plugin += Slider('mag_binary_ksize',
                         0,
                         31,
                         value=mag_binary_ksize,
                         value_type='int')
        plugin += Slider('mag_binary_thresh_low',
                         0,
                         255,
                         value=mag_binary_thresh_low,
                         value_type='int')
        plugin += Slider('mag_binary_thresh_high',
                         0,
                         255,
                         value=mag_binary_thresh_high,
                         value_type='int')
        plugin += Slider('dir_binary_ksize',
                         0,
                         31,
                         value=dir_binary_ksize,
                         value_type='int')
        plugin += Slider('dir_binary_thresh_low',
                         0,
                         np.pi,
                         value=dir_binary_thresh_low)
        plugin += Slider('dir_binary_thresh_high',
                         0,
                         np.pi,
                         value=dir_binary_thresh_high)

        fnames = [path for path in glob.iglob(search_pattern, recursive=True)]
        images, gray_images = read_images(fnames)

        self.viewer = CollectionViewer(images)
        self.viewer += plugin
Ejemplo n.º 8
0
    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:
# plugin += SaveButtons(name='Save overlay to:')

# Finally, attach the plugin to an image viewer.
viewer = ImageViewer(image)
viewer += plugin
viewer.show()[0][0]