python - 计算每个“像素”中的数据点
问题描述
我在编写一个函数时遇到问题,该函数将扫描(例如)10×10 像素区域以获取具有一定平均值的数据点数量。我的问题是在 x 轴上获得一个 10×10 的区域,同时保持 y 轴不变,然后一旦 x 轴“扫描”完成,在 y 轴上向上移动 10 个像素并在 x 轴上重复扫描。
# creating a standard to compare images against.
# from corner dark region with a lack of sources.
baseline = np.mean(
M91_master_image[0].data[1800:2000, 1800:2000]
+ 4 * (M91_master_image[0].data[1800:2000, 1800:2000].std())
)
mst_image_data = M91_master_image[0].data
o_y = 400
o_y2 = 2000
o_x = 400
o_x2 = 2000
s = 10 # pixel increments
x_array = []
y_array = []
while o_x < o_x2:
# print(o_x)
counts = mst_image_data[o_x:o_x + s, o_y:o_y + s]
if counts.mean() > baseline:
x_pos_c = (o_x + (o_x + s))/2
# print(x_pos_c)
x_array = np.append(x_array, x_pos_c)
# print(o_x)
y_pos_c = (o_y + (o_y + s))/2
y_array = np.append(y_array, y_pos_c)
o_y += s
o_x += s
print(x_array, y_array)
从图像中您可以看到我得到的是对角线:
解决方案
推荐阅读
- git - “-b”在“git checkout -b *insert_feature_branch_here*”中代表什么?
- java - OAUTH 从 2.0.0 升级到 2.3.3
- reactjs - Gatsby 图像未加载和无缓存问题
- php - PHP Ruflin/Elastica - 如何在大量数据插入时刷新索引
- websocket - WebSocket 连接到 NAT 后面的服务器
- arduino - TaskScehduler Arduino中的Task参数
- c# - 如何使 EF 通过 GroupJoin 急切加载集合导航属性?
- r - 如何在条件发生后过滤掉每组的行
- javascript - 用于显示值偏差的 javascript 图表库
- c++ - 如何使用 C++ 代码中的 BTRFS 写入时复制?