我有两个颜色图,它们都是使用 (n,n) 大小的数组创建的(n 是偶数)。
我只想显示具有一定强度的第二个颜色图的值。
如果第一个颜色图的渐变可以应用于第二个颜色图,那就更好了。
您可以创建一个由 0 和 1 组成的数组,其尺寸和大小与图像相同,并将强度高于阈值的值设置为 1,然后将偏振乘以该遮罩。
假设您有两个数组
intensity
和 polarisation
。 mask
数组将为 0,除非 intensity
位于 threshold
之上。
import numpy as np
intensity = np.ones((50,50)) * np.random.rand(50,50)
polarisation = np.ones((50,50))
threshold = 0.5
mask = np.zeros(np.shape(intensity))
mask[np.where(intensity>threshold)] = 1
filtered_polarisation = intensity * mask