-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.m
35 lines (28 loc) · 1.01 KB
/
main.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
30
31
32
33
34
35
clear; clc; close all;
%% Setup VLFeat toolbox.
%----------------------
addpath('modelspecific');
addpath('MBS'); % for saliency detection
cd vlfeat-0.9.21/toolbox;
feval('vl_setup');
cd ../..;
imgpath = 'Imgs\';
img_format = '*.jpg';
outpath = [imgpath, 'results\'];%testpatch
dir_folder = dir(strcat(imgpath, img_format));
if ~exist(outpath,'dir'); mkdir(outpath); end
path1 = sprintf('%s%s',imgpath, dir_folder(1).name); %
path2 = sprintf('%s%s',imgpath, dir_folder(2).name); %
img1 = im2double(imread(path1)); % target image
img2 = im2double(imread(path2)); % reference image
%% saliency detection
pMap_1 = mbs_saliency(img1);
pMap_2 = mbs_saliency(img2);
%% image alignment
fprintf('> image alignment...');tic;
[warped_img1, warped_pmap1, warped_img2, warped_pmap2] = registerTexture(img1, pMap_1, img2, pMap_2, imgpath);
fprintf('done (%fs)\n', toc);
%% image composition
fprintf('> seam cutting...');tic;
imgout = blendTexture(warped_img1, warped_pmap1, warped_img2, warped_pmap2);
fprintf('done (%fs)\n', toc);