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

📄 trailnum.m

📁 jpeg的matlab代码
💻 M
字号:
% trailnum - count trailing zeros in zigzag sequence%% SYNOPSIS%	trailnum(X)%% DESCRIPTION% 	JPEG-like compression leads to matrices which usually contain%	zeros in the high-frequency entries. Counting the number of%	trailing zeros (in the zigzag pattern) gives an indication of%	the compression achieved at the quantizing stage; trailnum%	returns this count.%% SEE ALSO%	jpeg, quant% Copyright (C) 1995-1997 Darrel Hankerson and Greg A. Harris%% This file is part of the JPEGtool collection of scripts for Octave% and Matlab; see http://www.dms.auburn.edu/compression%% The JPEGtool collection is free software; you can redistribute it% and/or modify it under the terms of the GNU General Public License% as published by the Free Software Foundation; either version 2, or% (at your option) any later version.%% The collection is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this package; see the file COPYING.  If not, write to the% Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA% 02111-1307, USA.function c = trailnum(a)n = size(a,1);[i, j] = find(a);if ~size(i,1)  % zero matrix?  c = n^2;  returnendw = sort(i+j); d = w(size(w, 1));% Count the number of zero entries in trailing zero diagonalsif (d <= n+1)  c = n^2 - (d-1)*d/2;else  c = (2*n-d)*(2*n-d+1)/2;end% Now count the number of trailing zeros in the last nonzero diagonalw = diag(rot90(a), d - n - 1);if (floor(d/2)*2 ~= d)  w = w(size(w,1):-1:1);endw = find(w); c = c + w(1) - 1;

⌨️ 快捷键说明

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