forked from emmay78/mEMbrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepLearningPredict.m
30 lines (23 loc) · 1.1 KB
/
deepLearningPredict.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [predictions] = deepLearningPredict(inputImage,network)
%DEEPLEARNINGPREDICT based on a trained network, make predictions for
%inputImage
% Uses semanticseg to make predictions based on a given trained network
% and input image
% NOTE: the training of network has to have happened on multiple of 32 px *
% 32 px.
size_image = size(inputImage);
inputImage = padarray(inputImage,32*ceil(size_image/32)-size_image,'symmetric','post');
[prediction, ~, probabilityMap] = semanticseg(inputImage, network, ...
'OutputType', 'uint8');
inputImage=inputImage(1:size_image(1),1:size_image(2));
prediction=prediction(1:size_image(1),1:size_image(2));
probabilityMap=probabilityMap(1:size_image(1),1:size_image(2),:);
prediction = 255 - (double(prediction)-1)*255;
probabilityMap = probabilityMap(:,:,1);
predictionWithInput = labeloverlay(inputImage, prediction);
probabilityWithInput = imfuse(inputImage, probabilityMap);
predictions.prediction = prediction;
predictions.probability = probabilityMap;
predictions.predictionWithInput = predictionWithInput;
predictions.probabilityWithInput = probabilityWithInput;
end