如何使用一个颜色图来过滤另一个颜色图上的数据?

问题描述 投票:0回答:1

我有两个颜色图,它们都是使用 (n,n) 大小的数组创建的(n 是偶数)。

第一个表示表面上光束的强度。 Intensity across the surface

另一个代表光束同时穿过同一表面的偏振。 Polarization of the beam acros the surface in °

我只想显示具有一定强度的第二个颜色图的值。

如果第一个颜色图的渐变可以应用于第二个颜色图,那就更好了。

python matplotlib plot colormap
1个回答
0
投票

您可以创建一个由 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
© www.soinside.com 2019 - 2024. All rights reserved.