Skip to content

Instantly share code, notes, and snippets.

@0xff07
Created January 15, 2018 02:28
Show Gist options
  • Save 0xff07/9b9ab6622e7ee3deb2809b595b27770b to your computer and use it in GitHub Desktop.
Save 0xff07/9b9ab6622e7ee3deb2809b595b27770b to your computer and use it in GitHub Desktop.
Matlab PIV Preprocess Program
HOMEPATH = '~/Downloads/VelocityImages/';
FOLD_NO = [5 10 20 30 40 50 55];
cd(HOMEPATH);
for i = 1:7
ORIGIN_FOLDER = [num2str(FOLD_NO(i)), '_files'];
CLEANED_FOLDER = [ORIGIN_FOLDER, '_cleaned'];
mkdir(CLEANED_FOLDER);
post = '.tif';
filename = [ORIGIN_FOLDER, '/', num2str(1), post];
background = double(imread(filename));
pre = 2;
while true
filename = [ORIGIN_FOLDER, '/', num2str(pre), post];
if ~exist(filename)
background = background / (pre - 1);
background = uint8(background);
break;
end;
img = imread(filename);
background = background + double(img);
pre = pre + 1;
end
imwrite(background, [CLEANED_FOLDER, '/', 'background.tif']);
pre = 1;
while true
filename = [ORIGIN_FOLDER, '/', num2str(pre), post];
if ~exist(filename)
break;
end
img = imread(filename);
img = img - background;
imwrite(img, [CLEANED_FOLDER, '/', num2str(pre), post]);
pre = pre + 1;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment