This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type | |
| // expands object types one level deep | |
| type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never; | |
| // expands object types recursively | |
| type ExpandRecursively<T> = T extends object | |
| ? T extends infer O ? { [K in keyof O]: ExpandRecursively<O[K]> } : never | |
| : T; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Macro for checking cuda errors following a cuda launch or api call | |
| #define cudaCheckError() { \ | |
| cudaError_t e=cudaGetLastError(); \ | |
| if(e!=cudaSuccess) { \ | |
| printf("Cuda failure %s:%d: '%s'\n",__FILE__,__LINE__,cudaGetErrorString(e)); \ | |
| exit(0); \ | |
| } \ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| readerClazz = importlib.import_module( | |
| 'reader.{}'.format(selectedReader)) # .py file level | |
| readerClazz = eval('readerClazz.{}'.format(selectedReader)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ssh-keygen -t rsa # if needed | |
| ssh-copy-id -i ~/.ssh/id_rsa.pub username@server_ip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def show_imgs(imgs, rows, cols=None, cmap='gray'): | |
| if rows == 1: | |
| cols = len(imgs) | |
| elif not cols: | |
| raise BaseException("Cannot infer `cols`.") | |
| plt.figure(); plt.tight_layout() | |
| code_base = int('{}{}1'.format(rows, cols)) | |
| for i in range(len(imgs)): | |
| plt.subplot(code_base); plt.imshow(imgs[i], cmap=cmap) | |
| code_base += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 直方图均衡化 | |
| void equalizeHist(uint8 *img, int h, int w) { | |
| // 计算各像素值的出现次数 | |
| float *freq = new float[256]; | |
| memset(freq, 0, 256 * sizeof(float)); | |
| for (int i = 0; i < h; i++) { | |
| for (int j = 0; j < w; j++) { | |
| short grayValue = img[i * h + j]; | |
| freq[grayValue] += 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _find_longest_all_true(arr): | |
| curlen = 0; maxlen = 0; p = 0; start_index = 0 | |
| while p < len(arr): | |
| if arr[p] == True: | |
| curlen += 1 | |
| elif curlen > maxlen: | |
| maxlen = curlen | |
| curlen = 0 | |
| start_index = p - maxlen | |
| p += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # 《数字信号处理》课程实验 | |
| # FIR数字滤波器设计 | |
| # 09017227 卓旭 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| plt.rcParams['font.sans-serif'] = ['KaiTi'] # 指定默认字体 | |
| plt.rcParams['axes.unicode_minus'] = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # 《数字信号处理》课程实验 | |
| # FFT与IFFT实测应用(作图) | |
| # 09017227 卓旭 | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from fft import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # 《数字信号处理》课程实验 | |
| # FFT与IFFT实现(一维) | |
| # 09017227 卓旭 | |
| import math | |
| ''' | |
| 自定义复数类 |
NewerOlder