コード例 #1
0
ファイル: helpers.py プロジェクト: dermen/cxid9114
def make_background_pixel_mask(DET, refls_strong=None):
    # make mask of all strong spot pixels..
    n_panels = len(DET)
    nfast, nslow = DET[0].get_image_size()
    # make a mask that tells me True if I am a background pixel
    is_bg_pixel = np.ones((n_panels, nslow, nfast), bool)
    # group the refls by panel ID
    if refls_strong is None:
        return is_bg_pixel

    refls_strong_perpan = prediction_utils.refls_by_panelname(refls_strong)
    for panel_id in refls_strong_perpan:
        panel_id = int(panel_id)
        fast, slow = DET[panel_id].get_image_size()
        mask = prediction_utils.strong_spot_mask_dials(
            refls_strong_perpan[panel_id], (slow, fast), as_composite=True)
        # dilate the mask
        mask = binary_dilation(mask, iterations=args.dilate)
        is_bg_pixel[
            panel_id] = ~mask  # strong spots should not be background pixels

    return is_bg_pixel
コード例 #2
0
                                                     BEAM,
                                                     thresh=args.thresh)
    if not refls_predict:
        print("refls_predictANK %d no spots!" % rank)
        continue
    n_predict = len(refls_predict)

    # make the spot integration foreground mask from the predictions
    panel_integration_masks = {}
    for pid in range(n_panels):
        panel_integration_masks[pid] = None
    # group predictions bty panel name
    refls_predict_bypanel = prediction_utils.refls_by_panelname(refls_predict)
    for panel_id in refls_predict_bypanel:
        fast, slow = DET[int(panel_id)].get_image_size()
        mask = prediction_utils.strong_spot_mask_dials(
            refls_predict_bypanel[panel_id], (slow, fast), as_composite=True)
        # if the panel mask is not set, set it!
        if panel_integration_masks[panel_id] is None:
            panel_integration_masks[panel_id] = mask
        # otherwise add to it   NOTE I think this is only for polychromatic...
        else:
            panel_integration_masks[panel_id] = np.logical_or(
                mask, panel_integration_masks[panel_id])

    # <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    # HERE WE LOAD THE STRONG SPOTS AND MAKE THEM INTO A MASK that can then be combined with the integration mask
    # such that the combination mask essentially tells us which pixels are background pixels
    # <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    # load strong spot reflections, these should be named after the images by stills process, hence the string manipulation
    refl_strong_fname = os.path.join(
        indexdirname,