-
Notifications
You must be signed in to change notification settings - Fork 1
/
imvolmerge.m
70 lines (54 loc) · 1.93 KB
/
imvolmerge.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function [C] = imvolmerge(vol1, vol2, varargin)
% inputs:
% imvolmerge(vol1, vol2)
% imvolmerge(vol{ch1, ch2}) - in the future
p = ParseInput(varargin{:});
s_title = p.Results.title;
hfig = p.Results.hfig;
SAVE_png = p.Results.png;
% Create figure for merged image
if ishandle(hfig)
% do nothing or give focus to
figure(hfig);
else
if ~isempty(hfig)
disp('(imvol) The input fig handle was not appropriate. New figure was created.');
end
pos = get(0, 'DefaultFigurePosition');
hfig = figure('Position',[pos(1)+pos(3)+100, pos(2), pos(3)*3, pos(4)]);
end
hfig.Color = 'none';
hfig.PaperPositionMode = 'auto';
hfig.InvertHardcopy = 'off';
% extend current axes to full canvas
axes('Position', [0 0 1 0.9524], 'Visible', 'off');
% Set the callback
set(hfig, 'WindowKeyPressFcn', @keypress);
% children figures inside parent figure
ax1 = subplot(1, 3, 1); % 1 by 2, select 1. subplot creats axes if it doesn't exist.
ax2 = subplot(1, 3, 2);
[A, param1] = imvol(vol1,'axes', ax1);
[B, param2] = imvol(vol2,'axes', ax2);
function redraw()
A = getimage(ax1);
B = getimage(ax2);
%figure(hfig); % give focus to parent figure
subplot(1, 3, 3);
[C, ~] = imfuse(A,B,'ColorChannels',[2 1 0]);
imshow(C);
end
% update image
redraw();
function keypress(~, evnt)
redraw();
end
end
function p = ParseInput(varargin)
p = inputParser; % Create an instance of the inputParser class.
addParamValue(p,'title', []);
addParamValue(p,'hfig', []);
addParamValue(p,'verbose', true, @(x) islogical(x));
addParamValue(p,'png', false, @(x) islogical(x));
% Call the parse method of the object to read and validate each argument in the schema:
p.parse(varargin{:});
end