forked from justinblaber/ncorr_2D_matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncorr_gui_loadroi.m
135 lines (120 loc) · 4.93 KB
/
ncorr_gui_loadroi.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function outstate = ncorr_gui_loadroi(img,roi,pos_parent)
% This is a mini GUI for displaying a loaded region of interest.
%
% Inputs -----------------------------------------------------------------%
% img - ncorr_class_img; single image used for displaying the background
% image.
% roi - ncorr_class_roi; used for displaying the ROI
% pos_parent - integer array; this is the position of the parent figure
% which determines where to position this figure
%
% Outputs ----------------------------------------------------------------%
% outstate - integer; returns either out.cancelled, out.failed, or
% out.success.
% Data ---------------------------------------------------------------%
% Initialize Output
outstate = out.cancelled;
% Get GUI handles
handles_gui = init_gui();
% Run c-tor
feval(ncorr_util_wrapcallbacktrycatch(@constructor,handles_gui.figure));
% Callbacks and functions --------------------------------------------%
function constructor()
% Set images
update_axes('set');
% Format window
set(handles_gui.figure,'Visible','on');
end
function callback_button_finish(hObject,eventdata) %#ok<INUSD>
% Set output
outstate = out.success;
% Exit
close(handles_gui.figure);
end
function callback_button_cancel(hObject,eventdata) %#ok<INUSD>
close(handles_gui.figure);
end
function update_axes(action)
if (strcmp(action,'set'))
% Overlay ROI over img
preview_roi = img.get_gs();
preview_roi(roi.mask) = preview_roi(roi.mask)+img.max_gs;
imshow(preview_roi,[img.min_gs 2*img.max_gs],'Parent',handles_gui.axes_preview);
set(handles_gui.axes_preview,'Visible','off');
set(handles_gui.text_name,'String',['Name: ' img.name(1:min(end,22))]);
end
end
function handles_gui = init_gui()
% GUI controls -------------------------------------------------------%
% Figure
handles_gui.figure = figure( ...
'Tag', 'figure', ...
'Units', 'characters', ...
'Position', ncorr_util_figpos(pos_parent,[35 126.7]), ...
'Name', 'Load ROI', ...
'MenuBar', 'none', ...
'NumberTitle', 'off', ...
'Color', get(0,'DefaultUicontrolBackgroundColor'), ...
'handlevisibility','off', ...
'DockControls','off', ...
'Resize','off', ...
'WindowStyle','modal', ...
'Visible','off', ...
'IntegerHandle','off', ...
'Interruptible','off');
% Panels
handles_gui.group_menu = uipanel( ...
'Parent', handles_gui.figure, ...
'Tag', 'group_menu', ...
'Units', 'characters', ...
'Position', [2 27.8 35 6.6], ...
'Title', 'Menu', ...
'Interruptible','off');
handles_gui.group_preview = uibuttongroup( ...
'Parent', handles_gui.figure, ...
'Tag', 'group_preview', ...
'Units', 'characters', ...
'Position', [38.7 0.75 85.8 33.6], ...
'Title', 'ROI Preview', ...
'Interruptible','off');
% Axes
handles_gui.axes_preview = axes( ...
'Parent', handles_gui.group_preview, ...
'Tag', 'axes_preview', ...
'Units', 'characters', ...
'Visible','off', ...
'Position', [2.4 3 80 28.6], ...
'Interruptible','off');
% Static texts
handles_gui.text_name = uicontrol( ...
'Parent', handles_gui.group_preview, ...
'Tag', 'text_name', ...
'Style', 'text', ...
'Units', 'characters', ...
'Position', [3 0.7 56.9 1.3], ...
'String', 'Name: ', ...
'HorizontalAlignment', 'left', ...
'Interruptible','off');
% Pushbuttons
handles_gui.button_finish = uicontrol( ...
'Parent', handles_gui.group_menu, ...
'Tag', 'button_finish', ...
'Style', 'pushbutton', ...
'Units', 'characters', ...
'Position', [2.1 3 29.7 1.7], ...
'String', 'Finish', ...
'Callback', ncorr_util_wrapcallbacktrycatch(@callback_button_finish,handles_gui.figure), ...
'Interruptible','off');
handles_gui.button_cancel = uicontrol( ...
'Parent', handles_gui.group_menu, ...
'Tag', 'button_cancel', ...
'Style', 'pushbutton', ...
'Units', 'characters', ...
'Position', [2.1 1 29.7 1.7], ...
'String', 'Cancel', ...
'Callback', ncorr_util_wrapcallbacktrycatch(@callback_button_cancel), ...
'Interruptible','off');
end
% Pause until figure is closed ---------------------------------------%
waitfor(handles_gui.figure);
end