class TestLogin(): def setup_class(self): self.login = PageLogin(getdriver()) def teardown_class(self): self.login.driver.quit() # 定义test方法,来输入,姓名,密码.点击登录 @pytest.mark.parametrize('username,password,result',demo.read()) def test_login(self,username,password,result): self.login.page_input_username(username) self.login.page_input_password(password) self.login.page_click_login_btn() print(result) # if __name__ == '__main__': # pytest.main()
# coding: utf-8 import matplotlib import matplotlib.pyplot as plt import numpy as np from skimage import io, util from skimage import data from scipy.ndimage import convolve from scipy.signal import medfilt from demo import read, show I = read('imgs/Fig0219.tif') show(I, 'raw_image', 'gray') # get an average filter r = 10 f = np.full((r, r), 1 / r**2) I1 = convolve(I, f) show(I1, 'after applying average filter', 'gray') def matlab_style_gauss2D(shape=(3, 3), sigma=0.5): """ 2D gaussian mask - should give the same result as MATLAB's fspecial('gaussian',[shape],[sigma]) """ m, n = [(ss - 1.) / 2. for ss in shape] y, x = np.ogrid[-m:m + 1, -n:n + 1] h = np.exp(-(x * x + y * y) / (2. * sigma * sigma)) h[h < np.finfo(h.dtype).eps * h.max()] = 0
import numpy as np from demo import read, show from skimage import transform img = read("../matlab_example/imgs/0401.tif") #tf_rotate = transform.SimilarityTransform(rotation=np.deg2rad(30)) #img = transform.warp(img, tf_rotate) #tf_shift = transform.SimilarityTransform(translation=[60, 60]) #img = transform.warp(img, tf_shift) show(img, cmap='gray') fft2 = np.fft.fft2(img) show(np.abs(fft2), cmap='gray') shift2center = np.fft.fftshift(fft2) show(np.abs(fft2), cmap='gray') log_fft2 = np.log(1 + np.abs(fft2)) show(np.abs(log_fft2), cmap='gray') log_shift2center = np.log(1 + np.abs(shift2center)) show(np.abs(log_shift2center), cmap='gray')
# coding: utf-8 import matplotlib import matplotlib.pyplot as plt import numpy as np from skimage import io, util from skimage import data from scipy.ndimage import convolve, laplace, sobel from scipy.signal import medfilt from demo import read, show I = read('imgs/lenna.tif') show(I, 'raw_image', 'gray') # apply laplace filter I1 = laplace(I) show(I1, 'after applying laplace filter', 'gray') # apply a gussian filter I2 = sobel(I) show(I2, 'after applying sobel filter', 'gray')
import numpy as np from demo import read, show raw_img = read("../matlab_example/imgs/0402.tif") img = np.pad(raw_img, ((0, raw_img.shape[0]), (0, raw_img.shape[1])), 'constant') show(img, cmap='gray') fft2 = np.fft.fft2(img) shift2center = np.fft.fftshift(fft2) show(np.log(1 + np.abs(shift2center)), cmap='gray') def dftuv(m, n): u = np.array(list(range(0, m))) v = np.array(list(range(0, n))) u[m // 2:] -= m v[n // 2:] -= n u, v = np.meshgrid(u, v) return u**2 + v**2 sigma = 0.05 * img.shape[0] d = dftuv(img.shape[0], img.shape[1]) h = np.exp(-d / (2 * (sigma**2))) res = np.fft.fft2(raw_img, (img.shape[0], img.shape[1])) * h res = np.fft.ifft2(res) show(np.abs(res), cmap='gray')
import demo demo.read()
# coding: utf-8 import matplotlib import matplotlib.pyplot as plt import numpy as np from skimage import io from skimage import data from scipy.ndimage import convolve from demo import read, show I = read('imgs/Fig0216.tif') show(I, 'raw_image') # get a filter f = np.ones((31, 31)) # nearest is same as replicate in matlab I1 = convolve(I, f, mode='nearest') I2 = convolve(I, f, mode='mirror') I3 = convolve(I, f, mode='constant', cval=0) show(I1, 'using nearest padding') show(I2, 'using mirror padding') show(I3, 'using constant 0 padding')