UNSW CV Assignment1
任务目标: 将一张背景深浅不一显微图的背景变成纯白,只留下作为观测对象的黑点
操作步骤:
1. 先生成一张,与input像素数完全相同的图片A,用N*N的max_filter去作用于input 类似于pooling 但是没有 strip 不知道要不要padding(应该不用)
2. 再生成一张图片B,遍历图A,取其N*N neighbourhood中的最小值,其中N是参数
3. 生成 Output O = I-B
注: 如果想要生成右图(白色背景黑色点),其实要 darkOutput = B-I , output = [[255]*img.shape[1]]*img.shape[0] - darkOutput
因为 I - B 减出来背景肯定是黑的,要用255颠倒一下,其实如果有需要也可以 Contrast Stretching 扩展一到0-255
任务二: 深色背景里取白色的点 ,让深色背景彻底变深
1. 生成 min-filter A of input
2. 生成 max-filter B of A
3. 生成OUTPUT = I-B ?
import cv2 as cv
import numpu as np
1. 读取 image :
img = cv.imread(path) # 路劲一定要加文件后缀 比如 .jpg等
2. 新建 image :
imgA = np.zeros([img.shape[0],img.shape[1],img.shape[2]],dtype=np.uint8)
3. 显示图像:
cv.imshow('img_name', img)
cv.waitKey() # 不加这行会一闪而过
4. 图片减法 https://blog.csdn.net/A_Z666666/article/details/81172083
函数原型:cv2.subtract(src1, src2, dst=None, mask=None, dtype=None)