nn_calc.py 文件源码

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

项目:tf_ViZDoom 作者: bounty030 项目源码 文件源码
def image_postprocessing_depth(gray, depth, t_size_y, t_size_x, feedback, t):

    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_gray_0_input.png', gray) 
        cv2.imwrite('feedback/image_' + str(t) + '_depth_0_input.png', gray) 

    # resize normal image
    gray = cv2.resize(gray, (t_size_y, t_size_x))
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_gray_1_resize.png', gray)

    # resize depth image
    depth = cv2.resize(depth, (t_size_y, t_size_x))
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_depth_1_resize.png', depth)

    # cut normal image
    gray = gray[t_size_y/2-1:-1,:]
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_gray_2_cut.png', gray)

    # cut depth image
    depth = depth[t_size_y/2-1:-1,:]
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_depth_2_cut.png', depth)

    # threshold filter for the grayscale image
    ret,gray = cv2.threshold(gray,160,255,cv2.THRESH_BINARY)

    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_gray_3_flt.png', gray)


    # custom filter for the depth image
    depth = cv2.bitwise_not(depth)
    ret, depth = cv2.threshold(depth,165,255,cv2.THRESH_TOZERO)

    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_depth_3_flt_inv.png', depth)

    height, width = depth.shape

    # subtract lowest gray-value
    minval = np.min(depth[np.nonzero(depth)])
    depth[np.nonzero(depth)] -= minval
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_depth_4_off.png', depth)

    # return the added image
    result = cv2.add(gray,depth)
    if feedback:
        cv2.imwrite('feedback/image_' + str(t) + '_final.png', result)

    return result

# calculates the gray-scale image from ViZDoom
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号