-
Notifications
You must be signed in to change notification settings - Fork 0
/
contrast.m
158 lines (125 loc) · 6.54 KB
/
contrast.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
function varargout = contrast(varargin)
% This GUI contains controls to change the values of CLAHE function.
hContrastFigure = findall(0, 'tag', 'contrast');
hMainFigure = findall(0, 'tag', 'maingui');
%Start Singleton
if (isempty(hMainFigure))
fprintf('Warning: This instance can not run whitout first execute the primary GUI\n');
return;
elseif (isempty(hContrastFigure))
% calculate the size and position in the screen of the GUI
sizeOfScreen = get(0,'ScreenSize');
position = sizeOfScreen;
x = position(3)/5;
y = position(4)/5;
position(1) = x;
position(2) = y;
position(3) = position(3) - x - x;
position(4) = position(4) - y - y;
hContrastFigure = figure('position', position, ...
'name', 'Contrast options', ... %'resize', 'off', ...
'numbertitle', 'off', 'dockcontrols', 'off', ...
'tag', 'contrast', 'menubar', 'none');
% containers
containerone = uiflowcontainer('units', 'norm', 'position', [0.03 0.03 0.94 0.2]);
set(containerone,'FlowDirection','lefttoright', 'margin', 10);
containertwo = uiflowcontainer('units', 'norm', 'position', [0.03 0.25 0.94 0.2]);
set(containertwo,'FlowDirection','lefttoright', 'margin', 10);
containerthree = uiflowcontainer('units', 'norm', 'position', [0.03 0.45 0.94 0.2]);
set(containerthree,'flowdirection','lefttoright', 'margin', 10);
containerfour = uiflowcontainer('units', 'norm', 'position', [0.03 0.65 0.94 0.2]);
set(containerfour,'flowdirection','lefttoright', 'margin', 10);
containerfive = uiflowcontainer('units', 'norm', 'position', [0.03 0.65 0.94 0.2]);
set(containerfive,'flowdirection','lefttoright', 'margin', 10);
containersix = uiflowcontainer('units', 'norm', 'position', [0.03 0.65 0.94 0.2]);
set(containersix,'flowdirection','lefttoright', 'margin', 10);
% contrast enhancement limit
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Contrast Enhancement Limit', ...
'units', 'normalized', ...
'position', [0.02 0.02 0.25 0.05],...
'parent', containertwo);
h2 = uicontrol(hContrastFigure, 'style', 'slider', ...
'min', 0, 'max', 1, 'sliderstep', [0.05 0.01], ...
'callback', @celCallback, ...
'units', 'normalized', ...
'position', [0.28 0.02 0.60 0.05], ...
'parent', containertwo);
set(h2, 'HeightLimits', [2, 50]);
celval = uicontrol(hContrastFigure, 'style', 'text', ...
'string', '0.0', ...
'units', 'normalized', ...
'position', [0.89 0.02 0.09 0.05], ...
'parent', containertwo);
% Number of tiles by row
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Tiles by Row', ...
'units', 'normalized', ...
'position', [0.02 0.18 0.25 0.05], ...
'parent', containerone);
h5 = uicontrol(hContrastFigure, 'style', 'slider', ...
'min', 0, 'max', 1, 'sliderstep', [0.05 0.01], ...
'callback', @tilesByRow, ...
'units', 'normalized', ...
'position', [0.28 0.18 0.60 0.05], ...
'parent', containerone);
set(h5, 'HeightLimits', [2, 50]);
tbrowval = uicontrol(hContrastFigure, 'style', 'text', ...
'string', '0.0', ...
'units', 'normalized', ...
'position', [0.89 0.18 0.09 0.05], ...
'parent', containerone);
% Number of tiles by column
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Tiles by Column', ...
'parent', containerthree);
h7 = uicontrol(hContrastFigure, 'style', 'slider', ...
'min', 0, 'max', 10, 'sliderstep', [0 0.01], ...
'callback', @tilesByRow, ...
'parent', containerthree);
set(h7, 'heightlimits', [2, 50]);
tbrowval = uicontrol(hContrastFigure, 'style', 'text', ...
'string', '0.0', ...
'parent', containerthree);
% Number of bins
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Number of bins', ...
'parent', containerfour);
uicontrol(hContrastFigure, 'style', 'slider', ...
'min', 0, 'max', 1024, ...
'sliderstep', [0 0.01], ...
'callback', @tilesByRow, ...
'parent', containerfour);
tbrowval = uicontrol(hContrastFigure, 'style', 'text', ...
'string', '0.0', ...
'parent', containerfour);
% Distribution
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Distribution', ...
'parent', containerfive);
dist = uicontrol(hContrastFigure, 'style', 'popupmenu', ...
'string', {'uniform', 'rayleigh', 'exponential'}, ...
'parent', containerfive);
% Range
uicontrol(hContrastFigure, 'style', 'text', ...
'string', 'Range', ...
'parent', containerfive);
dist = uicontrol(hContrastFigure, 'style', 'popupmenu', ...
'string', {'original', 'full'}, ...
'parent', containerfive);
%% ---[ end of uicontrol section ] ---
contrastGUIData.value = 100;
setappdata(hContrastFigure, 'childGUI', contrastGUIData);
else
figure(hContrastFigure);
end %end of Singleton
% --------------------- Functions and Callbacks -------------------------
function celCallback(hObject, eventdata)
value = get(hObject, 'value');
set(celval, 'string', value);
end
function tilesByRow(hObject, eventdata)
value = get(hObject, 'value');
set(tbrowval, 'string', value);
end
end