⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seperatekernel.m

📁 This function seperates a 2D matrix into its X and Y components if by definition the kernel is sepe
💻 M
字号:

%%
% This function seperates a 2D matrix into its X and Y components if by
% definition the kernel is seperable (rank==1). 
% Sample Usage:
%   G=fspecial('gaussian',3);   % Create a 3x3 Gaussian kernel.
%   [X Y]=SeperateKernel(G);
% I designed this algorithm to do automatic convolution. If the kernel is
% seperable one could easily use seperable convolution, while on the other
% hand if kernel cannot be seperated one could use FFT convolution.
function [X Y]=SeperateKernel(K)

% if rank is not 1, matrix is not seperable
if (rank(K)~=1)
    error('Matrix is not seperable');
end

% Compute Singular Value Decomposition
[U,S,V] = svd(K);

% Extract X from first column of U
X = U(:,1) * sqrt(S(1,1));

% Extract Y from first column of V
Y = V(:,1)' * sqrt(S(1,1));

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -