Switch to unified view

a b/3D Reconstruction/Interpolation/interpolate.m
1
function interpolate(inputDir, outputDir, new_depth, method)
2
% Interpolation between images 
3
%   inputDir: input image directory  
4
%   outputDir: output image directory
5
%   new_depth: new depth for 3-D volumetric intensity image
6
%   method: method for interpolating, choices are 'nearest', 'linear',
7
%                   'cubic', 'box', 'lanczos2', 'lanczos3'
8
imgDir  = dir([inputDir '*.png']); % 遍历目录内所有png格式文件
9
old_depth = length(imgDir);
10
img0 = imread([inputDir imgDir(1).name]);
11
num_rows = size(img0, 1);
12
num_cols = size(img0, 2);
13
images = zeros(num_rows, num_cols, old_depth);
14
for i = 1:length(imgDir)          
15
    images(:, :, i) =  imread([inputDir imgDir(i).name]); %¶ΑΘ΅ΓΏΥΕΝΌΖ¬
16
end
17
new_images = imresize3(images, [num_rows, num_cols, new_depth], method);
18
for idx = 1:size(new_images, 3)
19
    image = new_images(:, :, idx);
20
    imwrite(uint8(image), [outputDir num2str(idx), '.png']);
21
end
22
end
23