Advertisement
ridwan100

fm2bm

Dec 30th, 2023 (edited)
1,547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.76 KB | None | 0 0
  1. src_dir = '../uvmat/1/';
  2. dst_dir = '../bm/1/';
  3.  
  4. files = dir(src_dir);
  5. n = length(files);
  6.  
  7. % the loop should be modified based on how you organize your images
  8. parfor k = 1 : n
  9.     % check if the output directory exists, otherwise, create one
  10.     t = dst_dir;
  11.     if ~exist(t, 'dir')
  12.         mkdir(t);
  13.     end
  14.    
  15.     currf = files(k).name;
  16.     if ~isempty(strfind(currf, '.mat'))
  17.         fname = fullfile(src_dir, currf);
  18.         disp(k);
  19.         d = load(fname);
  20.         % read uv
  21.         uv = d.uv;
  22.         uv = im2single(uv);
  23.         % flip v
  24.         uv = cat(3, uv(:, :, 3), 1.0 - uv(:, :, 2), uv(:, :, 1));
  25.         % compute backward mapping
  26.         bm = uv2mp(uv);
  27.         % save file
  28.         save(fullfile(t, currf), 'bm','-v7');
  29.     end
  30. end
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement