How can each flagged pixel become one coordinate row?
argwhere groups nonzero coordinates by element. Each output row lists the indices of one position across its axes.
numpy.argwhere in practice
Two bright pixels export as two coordinate records. To index the original image, supply indices organized by axis. A coordinate table passed as one index has different semantics.
import numpy as np
np.argwhere([[0,0,1],[1,0,0]])Result [[0, 2], [1, 0]]
中文
怎样把每个异常像素写成一行坐标?
argwhere 将非零元素的位置按元素分组,每一行列出一个位置在所有轴上的下标。
numpy.argwhere 算例
两个亮点能直接导出为两条坐标记录。若目的是给原数组做高级索引,应按轴组织下标,不能将这张坐标表直接当作逐轴索引。
import numpy as np
np.argwhere([[0,0,1],[1,0,0]])结果 [[0, 2], [1, 0]]