def SobelFilter(img): x_filter = [[-1., 0., 1.], [-2., 0., 2.], [-1., 0., 1.]] y_filter = [[-1., -2., -1.], [0., 0., 0.], [1., 2., 1.]] # f_x = filters.sobel(img, axis=1, mode='constant', cval=0.0) # f_y = filters.sobel(img, axis=0, mode='constant', cval=0.0) g_x = custom_utils.handle_window(img, x_filter, custom_utils.sum_cross_mtx) g_y = custom_utils.handle_window(img, y_filter, custom_utils.sum_cross_mtx) u_mag = np.hypot(g_x, g_y) u_dir = np.arctan2(g_y, g_x) return u_mag, u_dir
def MeanFilter(img): # img = np.array(img) mean33 = [[1., 1., 1.], [1., 1., 1.], [1., 1., 1.]] win = np.array(mean33) / 9 # assumes zero pad. need to think about # print filters.convolve(img, win, mode='constant', cval=0) return custom_utils.handle_window(img, win, custom_utils.sum_cross_mtx)
def MedianFilter(img): # out = filters.median_filter(img, size=(3, 3), mode='constant', cval=0) return custom_utils.handle_window(img, DEFAULT33, custom_utils.median_cross_mtx, False)
def ComboFilter(img): out = custom_utils.handle_window(img, DEFAULT33, combo_func, False) out = np.clip(out, 0, 1) return out
def PixelFilter(img): out = custom_utils.handle_window(img, DEFAULT33, pixel_func, False) out = np.clip(out, 0, 1) return out