imageutils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:astrobase 作者: waqasbhatti 项目源码 文件源码
def extract_img_background(img_array,
                           custom_limits=None,
                           median_diffbelow=200.0,
                           image_min=None):
    '''
    This extracts the background of the image array provided:

    - masks the array to only values between the median and the min of flux
    - then returns the median value in 3 x 3 stamps.

    img_array = image to find the background for

    custom_limits = use this to provide custom median and min limits for the
                    background extraction

    median_diffbelow = subtract this value from the median to get the upper
                       bound for background extraction

    image_min = use this value as the lower bound for background extraction

    '''

    if not custom_limits:

        backmax = np.median(img_array)-median_diffbelow
        backmin = image_min if image_min is not None else np.nanmin(img_array)

    else:

        backmin, backmax = custom_limits

    masked = npma.masked_outside(img_array, backmin, backmax)
    backmasked = npma.median(masked)

    return backmasked


## IMAGE SECTION FUNCTIONS ##
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号