📄 imuieq.m
字号:
function CY = imuieq(varargin)
if ~ischar(varargin{1})
Action = '::::BuildGUI';
CX = varargin{1};
CPREV = thumb(CX, 150);
if isgray(CPREV)
CPREV = cat(3, CPREV, CPREV, CPREV);
end
else
Action = varargin{1};
ud = get(gcf, 'UserData');
end
switch Action
case '::::BuildGUI'
[L, x] = imhist(CX, 256);
ud.fig = figure( ...
'Position', [0 0 740 500], ...
'Name', 'Equalizer', ...
'BackingStore', 'on', ...
'Menubar', 'none', ...
'NumberTitle', 'off', ...
'Resize', 'off', ...
'HandleVisibility', 'on', ...
'WindowStyle', 'modal', ...
'Interruptible', 'off', ...
'Visible', 'off');
%%%%Build Context-Menu
ud.cmnu = uicontextmenu( 'Parent', ud.fig );
ud.colormap = uimenu( ud.cmnu, 'Label', '&Colormap');
ud.alpha = uimenu( ud.cmnu, 'Label', '&Transparency');
colormaps = { ...
'hsv','hot','gray','bone','copper','pink','white','flag', ...
'lines','colorcube','vga','jet','prism','cool','autumn', ...
'spring','winter','summer'};
for i = 1 : length(colormaps)
uimenu( ud.colormap, ...
'Label', ['&', char(i + 64 ), ' - ',colormaps{i}], ...
'UserData', colormaps{i}, ...
'Callback', 'colormap(get(gcbo, ''UserData''))')
end
for i = 0 : 10
switch i
case 0
uimenu( ud.alpha, ...
'Label', '&Clear ', ...
'Callback', 'alpha(''clear'')')
case 10
uimenu( ud.alpha, ...
'Label', '&Opaque ', ...
'UserData', i/10, ...
'Callback', 'alpha(''opaque'')')
otherwise
uimenu( ud.alpha, ...
'Label', ['&', num2str(i), ' - Alpha ',num2str(i/10)], ...
'UserData', i/10, ...
'Callback', 'alpha(get(gcbo, ''UserData''))')
end
end
%%%%2D - FR
ud.fr = axes( ...
'Units', 'pixel', ...
'Position', [35 250 220 220], ...
'Color', 'k', ...
'DrawMode', 'fast', ...
'XGrid', 'on', ...
'YGrid', 'on', ...
'FontSize', 8);
[f1,f2]=freqspace(48);
ud.hsurf= surf(f1, f2, zeros(48));
title('\bf\fontsize{9}2-D Frequency Response')
xlabel('\bfFrequency_x')
ylabel('\bfFrequency_y')
zlabel('\bfMagnitude')
set(ud.hsurf, ...
'EdgeAlpha', 0.2, ...
'FaceAlpha', 0.6, ...
'EraseMode', 'normal', ...
'FaceColor', 'interp', ...
'EdgeLighting', 'phong', ...
'FaceLighting', 'phong', ...
'CDataMapping', 'scaled', ...
'UIContextMenu', ud.cmnu)
set(ud.fr, ...
'XLim', [-1 1], ...
'YLim', [-1 1], ...
'XTick', [-1 -0.5 0 0.5 1], ...
'YTick', [-1 -0.5 0 0.5 1])
colormap jet
axis square
%%%%1D - FR
ud.axeseq = axes( ...
'Units', 'pixel', ...
'Position', [320 260 400 210], ...
'DrawMode', 'fast', ...
'Box', 'on', ...
'XLim', [0 1], ...
'YLim', [0 3], ...
'XGrid', 'on', ...
'YGrid', 'on', ...
'FontSize', 8, ...
'XTick', round(linspace(0, 1, 16) * 1000) / 1000, ...
'YTick', linspace(0, 3, 16));
xlabel('\bfNormalized Frequency');
ylabel('<< Dim \bf Magnitude \rm Brighten >>');
title('\bf\fontsize{9}1-D Frequency Response');
% line([0 1], [1 1], 'Color', 'k');
ud.linecp = line( ...
'XData', linspace(0, 1, 16), ...
'YData', zeros(1, 16), ...
'LineWidth', 1, ...
'LineStyle', '-', ...
'Color', [0 0.5 1], ...
'Marker', 's', ...
'MarkerSize', 8, ...
'MarkerEdgeColor', [0 0.2 1], ...
'MarkerFaceColor', 'none', ...
'EraseMode', 'xor');
ud.linefr = line( ...
'XData', linspace(0, 1, 16), ...
'YData', zeros(1, 16), ...
'LineWidth', 2, ...
'LineStyle', '-', ...
'Color', [1 0 0.4], ...
'EraseMode', 'xor');
%%%%Image Preview
ud.preview = axes( ...
'Units', 'pixel', ...
'Position', [55 35 150 150]);
ud.img = imshow(CPREV, 'notruesize');
set(ud.preview, ...
'Visible', 'off', ...
'DrawMode', 'fast')
set(ud.img, ...
'UserData', CPREV, ...
'EraseMode', 'xor')
%%%%UICONTROLS
ud.chkpreview2dfr = uicontrol( ...
'Style', 'checkbox', ...
'Units', 'pixel', ...
'Position', [85 195 100 20], ...
'String', 'Preview 2D-FR', ...
'Value', 1, ...
'Callback', 'imuieq(''::::cb_Preview2DFR'')');
ud.chkpreviewimg = uicontrol( ...
'Style', 'checkbox', ...
'Units', 'pixel', ...
'Position', [85 10 100 20], ...
'String', 'Preview image', ...
'Value', 0, ...
'Callback', 'imuieq(''::::cb_PreviewImage'')');
ud.chksnaptogrid = uicontrol( ...
'Style', 'checkbox', ...
'Units', 'pixel', ...
'Position', [320 195 100 24], ...
'String', 'Snap to grid', ...
'Value', 0);
ud.chknormalized = uicontrol( ...
'Style', 'checkbox', ...
'Units', 'pixel', ...
'Position', [420 195 100 24], ...
'String', 'Normalized', ...
'Value', 0, ...
'Callback', 'imuieq(''::::cb_Normalized'')');
ud.txt1 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [520 195 100 18], ...
'HorizontalAlignment', 'left', ...
'String', 'Kernel size :');
ud.popksize = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [580 197 40 18], ...
'BackgroundColor', 'w', ...
'String', cellstr(num2str([11:2:41]')), ...
'Value', 6, ...
'Callback', 'imuieq(''::::cb_KSize'')');
ud.txt2 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [320 155 90 18], ...
'HorizontalAlignment', 'right', ...
'String', 'Design Method :');
ud.popmethod = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [420 158 200 18], ...
'BackgroundColor', 'w', ...
'String', {'Frequency transformation', ...
'Frequency sampling', 'One-dimensional window',...
'Two-dimensional window'}, ...
'Callback', 'imuieq(''::::cb_Method'')');
ud.txt3 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [320 118 90 18], ...
'HorizontalAlignment', 'right', ...
'String', '1-D window :', ...
'Enable', 'off');
ud.popwindow1 = uicontrol( ...
'Style', 'popupmenu', ...
'Units', 'pixel', ...
'Position', [420 120 100 18], ...
'BackgroundColor', 'w', ...
'Value', 8, ...
'Enable', 'off', ...
'Callback', 'imuieq(''::::cb_Window1'')', ...
'String', {'Bartlett';
'Bartlett-Hanning';
'Blackman';
'Blackman-Harris';
'Bohman';
'Chebyshev';
'Gaussian';
'Hamming';
'Hann';
'Kaiser';
'Nuttall';
'Rectangular';
'Tukey';
'Triangular'});
ud.txt4 = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [320 90 90 18], ...
'HorizontalAlignment', 'right', ...
'String', '- :', ...
'Enable', 'off');
ud.edtpara = uicontrol( ...
'Style', 'edit', ...
'Units', 'pixel', ...
'Position', [420 90 60 20], ...
'BackgroundColor', 'w', ...
'HorizontalAlignment', 'left', ...
'String', '1', ...
'Enable', 'off', ...
'Callback', 'imuieq(''::::cb_Para'')');
ud.txtinfo = uicontrol( ...
'Style', 'text', ...
'Units', 'pixel', ...
'Position', [320 10 400 18], ...
'HorizontalAlignment', 'center', ...
'FontWeight', 'bold', ...
'String', '.');
ud.btnapply = uicontrol( ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [645 192 75 24 ], ...
'FontWeight', 'bold', ...
'String', 'Apply', ...
'Callback', 'imuieq(''::::cb_Apply'')');
ud.btncancel = uicontrol( ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [645 152 75 24 ], ...
'FontWeight', 'bold', ...
'String', 'Cancel', ...
'Callback', 'imuieq(''::::cb_Cancel'')');
ud.btnreset = uicontrol( ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [645 100 75 24 ], ...
'String', 'Reset', ...
'Callback', 'imuieq(''::::cb_Reset'')');
ud.btnexport = uicontrol( ...
'Style', 'pushbutton', ...
'Units', 'pixel', ...
'Position', [645 70 75 24 ], ...
'String', 'Export...', ...
'Callback', 'imuieq(''::::cb_Export'')');
ud.HotPoint = [];
ud.MouseState = 'release';
movegui(ud.fig, 'center')
set(ud.fig, ...
'Visible', 'on', ...
'UserData', ud, ...
'Color', get(0, 'DefaultUIControlBackgroundColor'), ...
'WindowButtonMotion', 'imuieq(''::::MouseMotion'')', ...
'WindowButtonDownFcn', 'imuieq(''::::MouseDown'')', ...
'WindowButtonUpFcn', 'imuieq(''::::MouseRelease'')', ...
'CloseRequestFcn', 'imuieq(''::::cb_Cancel'')');
waitfor(ud.fig, 'Visible', 'off')
if strcmp('apply', get(ud.btnapply, 'UserData'))
h = waitfig('Applying Equalizer');
convkernel = get(ud.fr, 'UserData');
if isempty(convkernel)
convkernel = zeros(3);
end
CY = imfilter(CX, convkernel, 'replicate');
delete(h)
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -