Based on your comment, I'm going to give the following speculative answer (without testing it):
if np.all(alphachannel3d[x] == (0, 0, 0)) & np.all(alphachannel3d[x + 3] == (255, 255, 255)) & np.all(alphachannel3d[x -3]==(255, 255, 255)):
alphachannel3d[x] = (255, 255, 255)