matlab 深度学习黑暗图片画质增强

Posted studyer_domi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了matlab 深度学习黑暗图片画质增强相关的知识,希望对你有一定的参考价值。

1、内容简介


501-可以交流、咨询、答疑

2、内容说明

clear
clc
close all
digitDatasetPath = './high_change_gray/';
imds = imageDatastore(digitDatasetPath, ...
    'IncludeSubfolders',true, ...
    'LabelSource','foldernames');
%%
imds.ReadSize = 8;
rng(0)
imds = shuffle(imds);
[imdsTrain,imdsVal,imdsTest] = splitEachLabel(imds,0.9,0.05);
dsTrainNoisy = transform(imdsTrain,@addNoiseS);
dsValNoisy = transform(imdsVal,@addNoiseS);
dsTestNoisy = transform(imdsTest,@addNoiseS);
dsTrain = combine(dsTrainNoisy,imdsTrain);
dsVal = combine(dsValNoisy,imdsVal);
dsTest = combine(dsTestNoisy,imdsTest);
%%=
dsTrain = transform(dsTrain,@Preprocess);
dsVal = transform(dsVal,@Preprocess);
dsTest = transform(dsTest,@Preprocess);
dsTrain = transform(dsTrain,@augmentImages);

%%=
exampleData = preview(dsTrain);
inputs = exampleData(:,1);
responses = exampleData(:,2);
minibatch = cat(2,inputs,responses);
figure
montage(minibatch','Size',[8 2])
title('输入 (左边) 和 输出 (右边)')

%%
imageLayer = imageInputLayer([400,400,1]);
% 下采样
encodingLayers = [ ...
    convolution2dLayer(3,64,'Padding','same'), ...
    reluLayer, ...
    maxPooling2dLayer(2,'Padding','same','Stride',2), ...
    convolution2dLayer(3,32,'Padding','same'), ...
    reluLayer, ...
    maxPooling2dLayer(2,'Padding','same','Stride',2)];
% 上采样
decodingLayers = [ ...
    UpsampleConvLayer(2,32), ...
    reluLayer, ...
    UpsampleConvLayer(2,64), ...
    reluLayer, ...
    convolution2dLayer(3,1,'Padding','same'), ...
    clippedReluLayer(0.9), ...
    regressionLayer];    

layers = [imageLayer,encodingLayers,decodingLayers];

options = trainingOptions('adam', ...
    'MaxEpochs',10, ...
    'MiniBatchSize',6, ...
    'ValidationData',dsVal, ...
    'Shuffle','every-epoch', ...
    'Plots','training-progress', ...
    'Verbose',false)
%%
% load("net1.mat")
net = trainNetwork(dsTrain,layers,options);
%%
% options = trainingOptions('ExecutionEnvironment','cpu');
ypred = predict(net,dsTest,'ExecutionEnvironment','cpu');
size(ypred)
inputImageExamples = preview(dsTest);
for num = 1:8
    figure
    montage(inputImageExamplesnum,ypred(:,:,:,num));
    imwrite(inputImageExamplesnum,FILENAME)
end
%% 
imds1 = imageDatastore("./pic", ...
    'IncludeSubfolders',true, ...
    'LabelSource','foldernames');
ypred = predict(net,imds1, 'ExecutionEnvironment','cpu');
%% 
num = 3;
a = inputImageExamplesnum;
b = ypred(:,:,:,num);
figure
montage(a, b);
title('origin')
temp = single(b);
temp = imresize(temp,[400,400]);
temp = rescale(temp);
figure
montage(a, temp);
title('augment')
% imwrite(inputImageExamplesnum,'./3_origin.jpg')
% imwrite(ypred(:,:,:,num),'./3_predict.jpg')

 

3、仿真分析

 

4、参考论文


 

以上是关于matlab 深度学习黑暗图片画质增强的主要内容,如果未能解决你的问题,请参考以下文章

深度学习中图片数据增强方法

深度学习的黑暗时代已来临?

深度学习中的数据增强技术

深度学习和目标检测系列教程 9-300:TorchVision和Albumentation性能对比,如何使用Albumentation对图片数据做数据增强

深度学习正则化---数据增强

深度学习目前几种热门的数据增强方法