基于深度学习的图像去雨


提出一种基于深度学习(卷积神经网络)的图像去雨框架,取得的效果优于已经存在的绝大多数方法
资源截图
代码片段和文件信息
# This tensorflow implementation of guided filter is from: H. Wu et al. “Fast End-to-End Trainable Guided Filter“ CPVR 2018.

# Web: https://github.com/wuhuikai/DeepGuidedFilter

import tensorflow as tf

def diff_x(input r):
    assert input.shape.ndims == 4

    left   = input[: :         r:2 * r + 1]
    middle = input[: : 2 * r + 1:         ] - input[: :           :-2 * r - 1]
    right  = input[: :        -1:         ] - input[: : -2 * r - 1:    -r - 1]

    output = tf.concat([left middle right] axis=2)

    return output


def diff_y(input r):
    assert input.shape.ndims == 4

    left   = input[: : :         r:2 * r + 1]
    middle = input[: : : 2 * r + 1:         ] - input[: : :           :-2 * r - 1]
    right  = input[: : :        -1:         ] - input[: : : -2 * r - 1:    -r - 1]

    output = tf.concat([left middle right] axis=3)

    return output


def box_filter(x r):
    assert x.shape.ndims == 4

    return diff_y(tf.cumsum(diff_x(tf.cumsum(x axis=2) r) axis=3) r)


def guided_filter(x y r eps=1e-8 nhwc=False):
    assert x.shape.ndims == 4 and y.shape.ndims == 4

    # data format
    if nhwc:
        x = tf.transpose(x [0 3 1 2])
        y = tf.transpose(y [0 3 1 2])

    # shape check
    x_shape = tf.shape(x)
    y_shape = tf.shape(y)

    assets = [tf.assert_equal(   x_shape[0]  y_shape[0])
              tf.assert_equal(  x_shape[2:] y_shape[2:])
              tf.assert_greater(x_shape[2:]   2 * r + 1)
              tf.Assert(tf.logical_or(tf.equal(x_shape[1] 1)
                                      tf.equal(x_shape[1] y_shape[1])) [x_shape y_shape])]

    with tf.control_dependencies(assets):
        x = tf.identity(x)

    # N
    N = box_filter(tf.ones((1 1 x_shape[2] x_shape[3]) dtype=x.dtype) r)

    # mean_x
    mean_x = box_filter(x r) / N
    # mean_y
    mean_y = box_filter(y r) / N
    # cov_xy
    cov_xy = box_filter(x * y r) / N - mean_x * mean_y
    # var_x
    var_x  = box_filter(x * x r) / N - mean_x * mean_x

    # A
    A = cov_xy / (var_x + eps)
    # b
    b = mean_y - A * mean_x

    mean_A = box_filter(A r) / N
    mean_b = box_filter(b r) / N

    output = mean_A * x + mean_b

    if nhwc:
        output = tf.transpose(output [0 2 3 1])

    return output

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-26 17:40  图像去雨(附代码)
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_code
     文件       60804  2016-01-14 11:10  图像去雨(附代码)TIP17_training_code1.jpg
     文件       53022  2017-02-28 11:47  图像去雨(附代码)TIP17_training_code100.jpg
     文件      360831  2016-03-03 19:06  图像去雨(附代码)TIP17_training_code1001.jpg
     文件       44139  2017-02-28 16:46  图像去雨(附代码)TIP17_training_code7.jpg
     文件       29234  2018-09-15 14:46  图像去雨(附代码)TIP17_training_code8.jpg
     文件       58118  2017-02-28 16:45  图像去雨(附代码)TIP17_training_code88.jpg
     文件       40066  2017-02-28 11:46  图像去雨(附代码)TIP17_training_code99.jpg
     文件        2318  2018-06-14 15:39  图像去雨(附代码)TIP17_training_codeGuidedFilter.py
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codeTrainData
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codeTrainDatainput
     文件       60804  2016-01-14 11:10  图像去雨(附代码)TIP17_training_codeTrainDatainput1.jpg
     文件       70171  2016-01-14 11:10  图像去雨(附代码)TIP17_training_codeTrainDatainput2.jpg
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codeTrainDatalabel
     文件      204181  2016-01-14 11:18  图像去雨(附代码)TIP17_training_codeTrainDatalabel1.jpg
     文件      292156  2016-01-14 11:09  图像去雨(附代码)TIP17_training_codeTrainDatalabel2.jpg
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_code\__pycache__
     文件        2241  2018-09-07 09:12  图像去雨(附代码)TIP17_training_code\__pycache__GuidedFilter.cpython-36.pyc
     文件        5424  2018-09-08 08:59  图像去雨(附代码)TIP17_training_code\__pycache__ raining.cpython-36.pyc
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codemodel
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codemodel est-model
     文件     9056300  2018-06-14 14:29  图像去雨(附代码)TIP17_training_codemodel est-modelmodel.data-00000-of-00001
     文件         821  2018-06-14 14:29  图像去雨(附代码)TIP17_training_codemodel est-modelmodel.index
     文件      190986  2018-06-14 14:29  图像去雨(附代码)TIP17_training_codemodel est-modelmodel.meta
     目录           0  2018-09-26 17:39  图像去雨(附代码)TIP17_training_codemodel-me
     文件         277  2018-09-07 21:18  图像去雨(附代码)TIP17_training_codemodel-mecheckpoint
     文件     9056300  2018-09-07 21:00  图像去雨(附代码)TIP17_training_codemodel-memodel-epoch-7900.data-00000-of-00001
     文件         821  2018-09-07 21:00  图像去雨(附代码)TIP17_training_codemodel-memodel-epoch-7900.index
     文件      190835  2018-09-07 21:00  图像去雨(附代码)TIP17_training_codemodel-memodel-epoch-7900.meta
     文件     9056300  2018-09-07 21:05  图像去雨(附代码)TIP17_training_codemodel-memodel-epoch-8000.data-00000-of-00001
............此处省略15个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)