The Code analysis of the FFDNet model

1. 读取图像并判断是否为灰度图,如为RGB图转化为灰度图,并读取图像的w、h

The Code analysis of the FFDNet model

 

2.数据格式转换:将uint8表示的读取图像矩阵变为double表示。

3.加入噪声,如果噪声水平$\sigma = 50 $则:  

$noise = \sigma/255.*randn(size(label))$

产生的和输入图像shape相同的additional white Gaussian noise

The Code analysis of the FFDNet model

4.将得到的噪声水平图和输入图像相加得到模型的输入:
The Code analysis of the FFDNet model

 

5.对图像的shape 进行调整,调整为偶数,先宽度再高度。

if mod(w,2)==1
input = cat(1,input, input(end,:)) ;
end

图像为401*383 经过这次调整后增加了一行为402*383

The Code analysis of the FFDNet model

if mod(h,2)==1
        input = cat(2,input, input(:,end)) ;
    end

图像为402*383 经过这次调整后增加了一行为402*384

The Code analysis of the FFDNet model

6.设置噪声水平图 noise 

$sigmas = \sigma/255$

Patch的产生

产生一个array 存储产生的patch: imdb.HRlabels  = zeros(patchsize, patchsize, nch, numPatches,'single');

1. 根据cshuffle洗牌后的序列,随机取出一张图片;

2.判断是否为gray,进行灰度化;

3.对图像进行旋转操作和翻转,提高样本的多样性。

4.对图像进resize进行缩放。

5.进行图像尺度信息的获取和数据类型的转化(转换为单精度im2single)

6.关键步骤通过两个循环在image上取patchSize大小和间隔stride大小进行滑动取patch

Patch产生的代码: web