-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch_computation.m
40 lines (30 loc) · 953 Bytes
/
switch_computation.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
function [source_swatches, target_swatches] = switch_computation(csource,gtarget)
prompt = 'Enter number of swatches\n';
nb_swatch = str2num(input(prompt,'s'));
for i=1:nb_swatch
subplot(211)
hold on
r(i)=imrect();
subplot(212)
hold on
r2(i)=imrect();
end
%close 1;
source_swatches = cell(1,nb_swatch);
target_swatches = cell(1,nb_swatch);
for i=1:nb_swatch
% % Rectangle position is given as [xmin, ymin, width, height]
pos_r = r(i).getPosition();
% % Round off so the coordinates can be used as indices
pos_r = round(pos_r);
% % Select part of the image
source_swatch = imcrop(csource, pos_r);
source_swatches{i} = source_swatch;
pos_r2 = r2(i).getPosition();
% % Round off so the coordinates can be used as indices
pos_r2 = round(pos_r2);
% % Select part of the image
target_swatch = imcrop(gtarget, pos_r2);
target_swatches{i} = target_swatch;
end
end