Is there a numpy builtin to reject outliers from a list

后端 未结 10 789
孤城傲影
孤城傲影 2020-11-28 18:00

Is there a numpy builtin to do something like the following? That is, take a list d and return a list filtered_d with any outlying elements removed

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 19:01

    For a set of images (each image has 3 dimensions), where I wanted to reject outliers for each pixel I used:

    mean = np.mean(imgs, axis=0)
    std = np.std(imgs, axis=0)
    mask = np.greater(0.5 * std + 1, np.abs(imgs - mean))
    masked = np.multiply(imgs, mask)
    

    Then it is possible to compute the mean:

    masked_mean = np.divide(np.sum(masked, axis=0), np.sum(mask, axis=0))
    

    (I use it for Background Subtraction)

提交回复
热议问题