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
Esempio n. 2
0
def go(img):
    def preprocess(img):
        U = {}
        V = {}
        s = {}
        for i in (0, 1, 2):
            res = svd(img[..., i], full_matrices=False)
            U[i] = np.mat(res[0])
            V[i] = np.mat(res[2])
            s[i] = res[1]
        return U, V, s

    U, V, s = preprocess(img)

    def display(_, _from, _to):
        res = np.zeros_like(img)
        for i in (0, 1, 2):
            _s = s[i].copy()
            _s[:_from] = 0
            _s[_to:] = 0
            S = np.mat(np.diag(_s))
            res[..., i] = U[i] * S * V[i]
        return res

    viewer = ImageViewer(img)
    plugin = Plugin(image_filter=display)
    plugin.name = ""
    plugin += Slider('_from', 0, len(s[0]), 0, 'int', update_on='move')
    plugin += Slider('_to', 0, len(s[0]), len(s[0]), 'int', update_on='move')
    viewer += plugin
    viewer.show()
Esempio n. 3
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
Esempio n. 4
0
def go(img):
    def preprocess(img):
        U = {}
        V = {}
        s = {}
        for i in (0, 1, 2):
            res = svd(img[...,i], full_matrices=False)
            U[i] = np.mat(res[0])
            V[i] = np.mat(res[2])
            s[i] = res[1]
        return U, V, s

    def display(_, R, G, B):
        rgb = (R, G, B)
        res = np.zeros_like(img)
        for i in (0, 1, 2):
            _s = s[i].copy()
            _s[:rgb[i]] = 0
            S = np.mat(np.diag(_s))
            res[...,i] = U[i]*S*V[i]
        return res

    def _display_all(RGB):
        if RGB in cache: return cache[RGB]
        cache[RGB] = display(None, RGB, RGB, RGB)
        return cache[RGB]

    if os.path.isfile(cache_fname):
        cache = pickle.load(open(cache_fname, "rb"))
        n = len(cache) - 1
        img = _display_all(n)
    else:
        U, V, s = preprocess(img)
        n = len(s[0])
        cache = {}
        for i in range(n + 1):
            print("caching", i)
            _display_all(i)
        with open(cache_fname, "wb") as fh:
            pickle.dump(cache, fh)
        print("wrote to:", cache_fname)


    def display_all(_, RGB):
        return _display_all(RGB)

    viewer = ImageViewer(img)
    plugin = Plugin(image_filter = display_all)
    plugin.name = ""
    plugin += Slider('RGB', 0, n, 0, 'int', update_on='move')
    viewer += plugin
    viewer.show()
Esempio n. 5
0
def go(img):
    def preprocess(img):
        U = {}
        V = {}
        s = {}
        for i in (0, 1, 2):
            res = svd(img[..., i], full_matrices=False)
            U[i] = np.mat(res[0])
            V[i] = np.mat(res[2])
            s[i] = res[1]
        return U, V, s

    U, V, s = preprocess(img)

    def display(_, R, G, B):
        rgb = (R, G, B)
        res = np.zeros_like(img)
        for i in (0, 1, 2):
            _s = s[i].copy()
            _s[rgb[i]:] = 0
            S = np.mat(np.diag(_s))
            res[..., i] = U[i] * S * V[i]
        return res

    def display_all(_, RGB):
        return display(_, RGB, RGB, RGB)

    viewer = ImageViewer(img)
    plugin = Plugin(image_filter=display)
    plugin.name = ""
    plugin += Slider('R', 0, len(s[0]), len(s[0]), 'int')
    plugin += Slider('G', 0, len(s[0]), len(s[1]), 'int')
    plugin += Slider('B', 0, len(s[0]), len(s[2]), 'int')
    viewer += plugin
    plugin = Plugin(image_filter=display_all)
    plugin.name = ""
    plugin += Slider('RGB', 0, len(s[0]), len(s[0]), 'int')
    viewer += plugin
    viewer.show()
Esempio n. 6
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
    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