📄 imuifade.m
字号:
function CY = imuifade(varargin)
%IMUIFADE
% Member of IMUI
% Kotaimen.C, 2002/05 - 2002/07, All Rights Reserved
if ~isstr(varargin{1})
Action = 'BuildGUI';
imuiud = varargin{1};
else
Action = varargin{1};
ud = get(gcbf, 'UserData');
end
switch Action
case 'BuildGUI'
ud.imuiud = imuiud;
LOADDATA = load(ud.imuiud.HistoryData(ud.imuiud.LastHistoryIndex).FileName);
img1 = thumb(LOADDATA.CX, 128);
LOADDATA = load(ud.imuiud.HistoryData(ud.imuiud.HistoryIndex).FileName);
img2 = thumb(LOADDATA.CX, 128);
for i = 1 : ud.imuiud.HistoryCount
HistoryActionList{i} = ud.imuiud.HistoryData(i).ActionName;
HistoryFileList{i} = ud.imuiud.HistoryData(i).FileName;
end
ud.fig = dialog( ...
'Position', [0 0 520 224], ...
'Name', 'Fade', ...
'HandleVisibility', 'on', ...
'WindowStyle', 'modal', ...
'Visible', 'off', ...
'CloseRequestFcn', 'imuifade(''::::cb_cancel'')' );
ud.axes1 = axes( ...
'Units', 'pixel', ...
'Position', [10 75 128 128]);
ud.txt1 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [10 200 128 18], ...
'String', 'Upper layer');
ud.pop1 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [10 36 128 24], ...
'BackgroundColor', 'w', ...
'String', HistoryActionList, ...
'Value', ud.imuiud.LastHistoryIndex, ...
'UserData', HistoryFileList, ...
'Callback', 'imuifade(''::::cb_pop1'')');
ud.img1 = imshow(img1, 'notruesize');
ud.axes2 = axes( ...
'Units', 'pixel', ...
'Position', [148 75 128 128]);
ud.txt2 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [148 200 128 18], ...
'String', 'Bottom layer');
ud.pop2 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [148 36 128 24], ...
'BackgroundColor', 'w', ...
'String', HistoryActionList, ...
'Value', ud.imuiud.HistoryIndex, ...
'UserData', HistoryFileList, ...
'Callback', 'imuifade(''::::cb_pop2'')');
ud.img2 = imshow(img2, 'notruesize');
ud.axes3 = axes( ...
'Units', 'pixel', ...
'Position', [300 75 128 128]);
ud.txt3 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [300 200 128 18], ...
'String', 'Result');
ud.img3 = imshow(img2, 'notruesize');
ud.pop3 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [300 36 128 24], ...
'BackgroundColor', 'w', ...
'String', {'Normal', 'Add', 'Subtract'}, ...
'Value', 1, ...
'Callback', 'imuifade(''::::cb_pop3'')');
ud.txt4 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [10 10 128 18], ...
'HorizontalAlignment', 'right', ...
'String', 'Transparency:');
ud.apply = uicontrol(ud.fig, ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [440 192 72 24], ...
'FontWeight', 'bold', ...
'String', 'Fade', ...
'Callback', 'imuifade(''::::cb_apply'')');
ud.close = uicontrol(ud.fig, ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [440 154 72 24], ...
'FontWeight', 'bold', ...
'String', 'Close', ...
'Callback', 'imuifade(''::::cb_cancel'')');
ud.sld = uicontrol( ...
'Style', 'slider', ...
'Units', 'pixel', ...
'Position', [148 10 280 18], ...
'String', 'Action2', ...
'Value', 1, ...
'Callback', 'imuifade(''::::cb_sld'')');
set(ud.img1, 'EraseMode', 'xor', 'CDataMapping', 'scaled')
set(ud.img2, 'EraseMode', 'xor', 'CDataMapping', 'scaled')
set(ud.img3, 'EraseMode', 'xor', 'CDataMapping', 'scaled')
if strcmp(ImageType(img1), ImageType(img2)) ...
& strcmp( class(img1), class(img2) )
set(ud.sld, 'Enable', 'on')
set(ud.pop3, 'Enable', 'on')
set(ud.apply, 'Enable', 'on')
else
set(ud.sld, 'Enable', 'off')
set(ud.pop3, 'Enable', 'off')
set(ud.apply, 'Enable', 'off')
end
movegui(ud.fig, 'center')
set(ud.fig, ...
'UserData', ud, ...
'Visible', 'on', ...
'Colormap', gray(256))
waitfor(ud.fig, 'Visible', 'off')
if strcmp('apply', get(ud.apply, 'UserData'))
LOADDATA = load(HistoryFileList{get(ud.pop1, 'Value')});
CX1 = LOADDATA.CX;
LOADDATA = load(HistoryFileList{get(ud.pop2, 'Value')});
CX2 = LOADDATA.CX;
a = get(ud.sld, 'Value');
m = get(ud.pop3, 'Value');
CY = FadeFCN(CX1, CX2, a, m);
else
CY = [];
end
delete(ud.fig)
case '::::cb_pop1'
HistoryFileList = get(ud.pop1, 'UserData');
HistoryFileIndex = get(ud.pop1, 'Value');
LOADDATA = load(HistoryFileList{HistoryFileIndex});
img1 = thumb(LOADDATA.CX, 128);
img2 = get(ud.img2, 'CData');
set(ud.sld, 'Value', 1);
set(ud.img1, 'CData', img1)
set(ud.img2, 'CData', img2)
set(ud.img3, 'CData', img2)
if strcmp(ImageType(img1), ImageType(img2)) ...
& strcmp( class(img1), class(img2) )
set(ud.sld, 'Enable', 'on')
set(ud.apply, 'Enable', 'on')
else
set(ud.sld, 'Enable', 'off')
set(ud.apply, 'Enable', 'off')
end
case '::::cb_pop2'
HistoryFileList = get(ud.pop2, 'UserData');
HistoryFileIndex = get(ud.pop2, 'Value');
LOADDATA = load(HistoryFileList{HistoryFileIndex});
img1 = get(ud.img1, 'CData');
img2 = thumb(LOADDATA.CX, 128);
set(ud.sld, 'Value', 1);
set(ud.img1, 'CData', img1)
set(ud.img2, 'CData', img2)
set(ud.img3, 'CData', img2)
if strcmp(ImageType(img1), ImageType(img2)) ...
& strcmp( class(img1), class(img2) )
set(ud.sld, 'Enable', 'on')
set(ud.apply, 'Enable', 'on')
else
set(ud.sld, 'Enable', 'off')
set(ud.apply, 'Enable', 'off')
end
case '::::cb_sld'
a = get(ud.sld, 'Value');
m = get(ud.pop3, 'Value');
CX1 = get(ud.img1, 'CData');
CX2 = get(ud.img2, 'CData');
set(ud.img3, 'CData', ...
FadeFCN(CX1, CX2, a, m))
case '::::cb_pop3'
a = get(ud.sld, 'Value');
m = get(ud.pop3, 'Value');
CX1 = get(ud.img1, 'CData');
CX2 = get(ud.img2, 'CData');
set(ud.img3, 'CData', ...
FadeFCN(CX1, CX2, a, m))
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
function CY = FadeFCN(CX1, CX2, a, m)
switch m
case 1
CY = imlincomb((1-a), CX1, a, CX2);
case 2
CY = imadd( CX2, imlincomb(1-a, CX1));
case 3
CY = imsubtract( CX2, imlincomb(1-a, CX1));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -