reduce_size.m

来自「MATLAB Code for Optimal Quincunx Filter 」· M 代码 · 共 34 行

M
34
字号
function [y, ny] = reduce_size(y, ny, esp)
% remove small coefficients with absolute value less than esp 
% and revise the index of the element at the upperleft corner
% Copyright (c) 2006 Yi Chen

y = y.*(abs(y) > esp);

if y == 0
    y = 0;
else    % remove extra zeros
    sizey = size(y);
    while(sum(abs(y(sizey(1),:)))==0)
        y = y(1:sizey(1)-1,:);
        sizey = size(y);
    end
    
    while(sum(abs(y(1,:)))==0)
        sizey = size(y);
        y = y(2:sizey(1),:);
        ny(1) = ny(1) + 1;
    end
    
    sizey = size(y);
    while(sum(abs(y(:,sizey(2))))==0)
        y = y(:,1:sizey(2)-1);
        sizey = size(y);
    end
    
    while(sum(abs(y(:,1)))==0)
        sizey = size(y);
        y = y(:,2:sizey(2));
        ny(2) = ny(2) + 1;    
    end    
end

⌨️ 快捷键说明

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