📄 imuimerge.m
字号:
function imuimerge(varargin)
%IMUIMERGE
% Member of IMUI
% Kotaimen.C, 2002/05 - 2002/07, All Rights Reserved
error(nargchk(1, 1, nargin))
if ~isstr(varargin{1})
Action = '::::BuildGUI';
imuifigs =varargin{1};
else
Action = varargin{1};
ud = get(gcbf, 'UserData');
end
switch Action
case '::::BuildGUI'
j = 2;
grayimglist = {'[Select a grayscale image]'};
for i = imuifigs
imuiud = get(i, 'UserData');
if strcmp(imuiud.ImageType, 'Gray')
grayimglist{j} = imuiud.ImageTitle;
hdllist(j - 1) = imuiud.ImageHandle;
j = j + 1;
end
end
ud.fig = dialog( ...
'Position', [0 0 385 165], ...
'Name', 'Merge Channels', ...
'HandleVisibility', 'on', ...
'WindowStyle', 'modal', ...
'Visible', 'off', ...
'CloseRequestFcn', 'imuimerge(''::::cb_cancel'')' );
ud.txt1 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'HorizontalAlignment', 'right', ...
'Position', [10 128 70 20], ...
'String', 'Channel R:');
ud.pop1 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [90 128 196 24], ...
'BackgroundColor', 'w', ...
'String', grayimglist, ...
'Value', 1, ...
'Callback', 'imuimerge(''::::cb_pop1'')');
ud.txt2 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'HorizontalAlignment', 'right', ...
'Position', [10 100 70 20], ...
'String', 'Channel G:');
ud.pop2 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [90 100 196 24], ...
'BackgroundColor', 'w', ...
'String', grayimglist, ...
'Value', 1, ...
'Callback', 'imuimerge(''::::cb_pop1'')');
ud.txt3 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'HorizontalAlignment', 'right', ...
'Position', [10 72 70 20], ...
'String', 'Channel B:');
ud.pop3 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [90 72 196 24], ...
'BackgroundColor', 'w', ...
'String', grayimglist, ...
'Value', 1, ...
'Callback', 'imuimerge(''::::cb_pop1'')');
ud.txt4 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'HorizontalAlignment', 'right', ...
'Position', [110 10 70 20], ...
'String', 'Merge into:');
ud.pop4 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [190 10 96 24], ...
'BackgroundColor', 'w', ...
'String', {'RGB image', 'HSV image', 'LCbCr image'}, ...
'Value', 1, ...
'Callback', 'imuimerge(''::::cb_pop4'')');
ud.apply = uicontrol(ud.fig, ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [300 128 72 24], ...
'String', 'Merge', ...
'FontWeight', 'bold', ...
'Enable', 'off', ...
'Callback', 'imuimerge(''::::cb_apply'')');
ud.close = uicontrol(ud.fig, ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [300 90 72 24], ...
'FontWeight', 'bold', ...
'String', 'Close', ...
'Callback', 'imuimerge(''::::cb_cancel'')');
movegui(ud.fig, 'center')
set(ud.fig, ...
'UserData', ud, ...
'Visible', 'on')
waitfor(ud.fig, 'Visible', 'off')
if strcmp('apply', get(ud.apply, 'UserData'))
ch1 = get(hdllist(get(ud.pop1, 'Value')-1), 'CData');
ch2 = get(hdllist(get(ud.pop2, 'Value')-1), 'CData');
ch3 = get(hdllist(get(ud.pop3, 'Value')-1), 'CData');
if all([size(ch1) == size(ch2), size(ch2) == size(ch3), ...
strcmp(class(ch1), class(ch2)), strcmp(class(ch1), class(ch2))])
switch get(ud.pop4, 'Value')
case 1
imui(cat(3, ch1, ch2, ch3))
case 2
imui(hsv2rgb( im2double(cat(3, ch1, ch2, ch3))))
case 3
imui(ycbcr2rgb( cat(3, ch1, ch2, ch3)))
end
else
prompt = 'Channels must be same size and class.';
h = errordlg(prompt, 'imui', ...
struct('Interpreter', 'tex', 'WindowStyle', 'modal') );
end
end
delete(ud.fig)
case '::::cb_pop1'
pop1v = get(ud.pop1, 'Value');
pop2v = get(ud.pop2, 'Value');
pop3v = get(ud.pop3, 'Value');
if all([pop1v > 1,pop2v > 1, pop3v > 1])
set(ud.apply, 'Enable', 'on')
else
set(ud.apply, 'Enable', 'off')
end
case '::::cb_pop4'
switch get(ud.pop4, 'Value')
case 1
set(ud.txt1, 'String', 'Channel R:')
set(ud.txt2, 'String', 'Channel G:')
set(ud.txt3, 'String', 'Channel B:')
case 2
set(ud.txt1, 'String', 'Channel H:')
set(ud.txt2, 'String', 'Channel S:')
set(ud.txt3, 'String', 'Channel V:')
case 3
set(ud.txt1, 'String', 'Channel Y:')
set(ud.txt2, 'String', 'Channel Cb:')
set(ud.txt3, 'String', 'Channel Cr:')
end
case '::::cb_apply'
set(ud.apply, 'Userdata', 'apply')
set(ud.fig, 'Visible', 'off')
case '::::cb_cancel'
set(ud.apply, 'Userdata', 'cancel')
set(ud.fig, 'Visible', 'off')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -