探索flutter框架开发的app在移动应用市场的潜力与挑战
821
2022-09-30
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({inputImageExamples{num},ypred(:,:,:,num)});
imwrite(inputImageExamples{num},FILENAME)
end
%%
imds1 = imageDatastore("./pic", ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
ypred = predict(net,imds1, 'ExecutionEnvironment','cpu');
%%
num = 3;
a = inputImageExamples{num};
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(inputImageExamples{num},'./3_origin.jpg')
% imwrite(ypred(:,:,:,num),'./3_predict.jpg')
3、仿真分析
4、参考论文
略
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~