Created
February 21, 2020 07:31
-
-
Save mightbesimon/26c76f184a61a54757d5cb0b5ae1c350 to your computer and use it in GitHub Desktop.
UoA Engineering ENGGEN 131 s2 2019 MATLAB project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [medianImage , maxImage] = SixLiner(dirName , fileType) | |
% SixLiner: does the matlab project in six lines of code | |
% | |
% inputs : dirName = directory of the images | |
% fileType = file extension type of the images | |
% outputs :medianImage = image background | |
% maxImage = images combined on background | |
% | |
% by simon shan | |
% ---------------- 6 lines ---------------- % | |
dirFiles = dir(dirName + "/*." + fileType); | |
images = cellfun(@imread , dirName+ "/" + {dirFiles.name}, 'UniformOutput', false); | |
% remove action % | |
medianImage = median(cat(4 , images{:}) , 4); | |
% action shot % | |
[~,index] = max(sum((double(cat(4 , images{:})) - double(medianImage)) .^ 2 , 3) , [] , 4); | |
layerIndex(1 , 1 , 1 , 1:length(images)) = 1 : length(images); | |
maxImage = uint8(sum(double(cat(4 , images{:})) .* (index == layerIndex) , 4)); | |
% ---------------- 6 lines ---------------- % | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment