【发布时间】:2021-04-12 17:45:36
【问题描述】:
基本上只是按照 Tital 所说的去做,我有一个工作功能,但它的运行速度很慢。此函数的输入图像将始终具有相同的形状和尺寸 (2d)。
这是我的工作但速度慢的代码
def z_score_detect():
data = currentData - bkgData
tileY =12
tileX =12
h,w = data.shape
DETECTED = np.zeros(data.shape).astype(np.float32)
for curY in range(tileY//2, h-tileY//2,tileY//2):
for curX in range(tileX//2, w-tileX//2,tileX//2):
# Get one of the patches of data
S = data[curY-tileY//2:curY+tileY//2,curX-tileX//2:curX+tileX//2]
# comput stdev, median
rms_bot_75 = rms(np.sort(S,axis=None)[:int((tileX*tileY)*.75)])
std_dev = np.std(S)
if std_dev != 0:
# IF SIGMA NOT ZERO
S = (S-rms_bot_75)/std_dev
# Done with processing this patch so update our output image
else:
continue
DETECTED[curY-tileY//2:curY+tileY//2,curX-tileX//2:curX+tileX//2] = np.maximum(S,DETECTED[curY-tileY//2:curY+tileY//2,curX-tileX//2:curX+tileX//2])
return DETECTED
【问题讨论】:
标签: python numpy computer-vision