-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgetinput.m
55 lines (49 loc) · 1.6 KB
/
getinput.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function getinput(varargin)
%GETINPUT obtains user input
%
% GETINPUT(PRAN) specifies the user input for the images in data
% path specified by their index PRAN in alphabetical order.
%
% Example
% -------
% getinput(200); % remove shadow from 1 image and show information
% getinput(1:2); % remove shadow from 1 image and show information
% Copyright Han Gong 2016
addpath('functions'); % path of general functions
paths = datapath(true); % add image path
[imgs,img_name] = loadimlist(paths); % load image list
len = size(img_name,1);
path = 'in/';
wz = 6;
if ~exist(path,'dir'), mkdir(path); end
if nargin==1, lset = varargin{1}; else lset = 1:len; end
for i = lset
im = imread(imgs{i});
imsz = size(im); imhw = imsz(1:2);
% sample area extraction
imshow(im); % display image
msk = zeros(imhw);
title('Select Lit Pixels');
while true % get lit pixels
[~,x,y] = freehanddraw(gca,'color','r','linewidth',wz); % get xy
if length(x)>2
tmsk = xy2msk([x,y]',imhw,wz); % convert xy to mask
msk = msk + tmsk;
else break;
end
end
title('Select Shadow Pixels');
while true % get shadow pixels
[~,x,y] = freehanddraw(gca,'color','b','linewidth',wz); % get xy
if length(x)>2
tmsk = xy2msk([x,y]',imhw,wz); % convert xy to mask
msk = msk + 0.5*tmsk;
else break;
end
end
imwrite(msk,[path,img_name{i},'.png']);
end
close gcf;
rmpath('functions'); % path of general functions
datapath(false);
end