找回密码
 注册
关于网站域名变更的通知
查看: 529|回复: 1
打印 上一主题 下一主题

MATLAB 信号处理工具箱之 idct 介绍和案例分析

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-12-27 10:08 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x

3 J* w7 s. r; A) i6 j有关idct的基础知识见:MATLAB 基础知识之逆离散余弦变换(idct)8 d! o. a) N" H& P
: [& Y% |) I- x( Z( ^3 s1 E- h
idct
/ z9 C+ L0 W% g% D# C7 }1 k' u3 W# v! p: {4 Y
逆离散余弦变换
! C& H: n% g  v" a: W) Z0 v. D9 ]& q" \
Syntax) b7 v, u, ^1 s0 o- {* _3 [
9 x* J( [1 B( ]. i; B
x = idct(y)$ F# y1 T. C! W4 _

3 a$ }2 g2 u% d- Q$ Xx = idct(y,n)
9 d4 W1 p' V5 t1 a9 W
0 L6 O* ?, c0 H! B' |x = idct(y,n,dim)) W4 Y, s# v! S

" Q3 Y, O6 g% J& p7 fy = dct(___,'Type',dcttype)
2 B+ S3 ]1 d9 a1 [3 V, a
- \6 ?% P) U. f5 ?  D% o$ lDescription$ r0 n" D- p& U% g8 U# a

# F. m9 P" r  n4 x6 T  J' hx = idct (y) 返回输入数组 y 的逆离散余弦变换。输出 x 的大小与 y 相同。如果 y 具有多个维度, 则 idct 沿第一个数组维度运行, 大小大于1。
; W( j; I+ y. Y2 t( [% m$ [% W8 l* c; |$ V3 t% v) A" |
x = idct (y, n) 填充0或截断 y 到长度 n 在转换前的相关维度。# b3 Z8 t7 ?% G& B# d: H/ a8 y5 t
; y* q) [) l/ Y( D* z8 e9 C
x = idct (y、n、dim) 计算沿维度dim的变换。若要输入维度并使用默认值 n, 请将第二个参数指定为空 []。
4 Y! f. D+ d- D; A4 Q0 d3 J1 e" }  N7 A+ {9 b# f3 E
y = dct(___,'Type',dcttype) specifies the type of inverse discrete cosine transform to compute. $ x9 H/ Z# Y! M! d4 L6 U* Y
# C! H! c) y4 N* s9 C3 F
Signal Reconstruction Using Inverse Discrete Cosine Transform

! N4 n+ P& q. w/ n, W$ f6 M, G( {, B1 c) m/ N+ t) K3 o6 g3 W
生成一个信号, 由 25 hz 正弦采样 1000 hz 1 秒。正弦波嵌入在具有方差0.01 的白色高斯噪声中。3 c0 i6 T4 h7 ?- ~) G, ^

$ S8 `; U1 T( j0 C( M$ x
  • clc
  • clear
  • close all
  • % Generate a signal that consists of a 25 Hz sinusoid sampled at 1000 Hz for 1 second.
  • % The sinusoid is embedded in white Gaussian noise with variance 0.01.
  • rng('default')
  • Fs = 1000;
  • t = 0:1/Fs:1-1/Fs;
  • x = sin(2*pi*25*t) + randn(size(t))/10;
  • % 计算序列的离散余弦变换。
  • % 确定1000个 DCT 系数中有多少是显著的。
  • % 选择1作为重要性的阈值。
  • y = dct(x);
  • sigcoeff = abs(y) >= 1;
  • howmany = sum(sigcoeff)
  • % Reconstruct the signal using only the significant components.
  • y(~sigcoeff) = 0;      %~ means not
  • z = idct(y);
  • % Plot the original and reconstructed signals.
  • subplot(2,1,1)
  • plot(t,x)
  • yl = ylim;
  • title('Original')
  • subplot(2,1,2)
  • plot(t,z)
  • ylim(yl)
  • title('Reconstructed')7 G: l+ m2 L) d: c* \( `+ i* l
            
3 X8 n8 ]# A0 n6 n' O% u- g上面这段程序中,简单地做几点解释:
9 i) y* G1 \  _. T( y7 ^5 \* M0 @  R' p% d! T/ _8 E
sigcoeff = abs(y) >= 1;4 L% r# F5 Y  D$ x' ~5 y

$ f: f) R1 ^* L( j1 W由于1是阈值,所以判断向量y中元素大于阈值的元素个数,这条语句可以改写为:sigcoeff = ( abs(y) >= 1 ) ;这样可以更清晰。$ [% Y; ?& M; A8 t3 U6 _; d: z

% ^3 D1 C2 ~; hsigcoeff向量中得到的是逻辑值,元素1代表该位置的系数元素大于阈值。' _6 Y; [( W: r. |* k7 ^- H
: U1 ], B8 S& }
后面用语句:howmany = sum(sigcoeff);
# ?0 Z( A1 x# [$ X3 c
8 b+ K; b# s8 [+ I- F5 a# n得到系数中大于阈值的个数,也就是重要系数个数。
6 H  u  U. ^7 r0 e  P; p. m- D: t. w; m( m
y(~sigcoeff) = 0;      %~ means not
. X  M4 B; P/ s% b
" H' u7 [; D5 W这条语句的意思是将系数中的不重要的系数都置零。7 L6 @: s, Q( r, C4 S, {& E$ G3 W

! V' W1 x* J2 G) c. j最后:yl = ylim;表示获取当前x,y坐标轴的限制。
( Z' V  E9 q8 z. v4 T+ l/ N! P
ylim(yl);表示当前画图的x,y坐标轴的限制和yl一致。
5 W& W8 J5 R% y' I3 A9 V4 U
0 Z- Q1 {: d- q: L4 M结果为:. b- L' E6 y4 I; Y" |6 t7 K

) r7 W" Y/ y5 W7 ]$ J* t5 L7 x * f/ `4 J6 N' k' d
& Y. a8 C0 R0 L6 ?4 c: i, v' y
DCT Orthogonality0 }9 N/ w/ m- D: m5 c9 f3 R
, ~, j5 f: ^$ j5 J2 q! w3 V. @* d3 X
验证离散余弦变换的不同变体是否正交, 使用随机信号作为基准。- Y; ]: ~+ b9 ?9 i( G
( r( c9 ^/ o, j# I- F/ a: |
从生成信号开始。
0 |- H0 s( }0 F) Y6 P! v
, z2 g4 M) e! B
  • clc
  • clear
  • close all
  • % Verify that the different variants of the discrete cosine transform are orthogonal, using a random signal as a benchmark.
  • %
  • % Start by generating the signal.
  • s = randn(1000,1);
  • % Verify that DCT-1 and DCT-4 are their own inverses.
  • dct1 = dct(s,'Type',1);
  • idt1 = idct(s,'Type',1);
  • max(abs(dct1-idt1))
  • % ans = 1.3323e-15
  • dct4 = dct(s,'Type',4);
  • idt4 = idct(s,'Type',4);
  • max(abs(dct4-idt4))
  • % ans = 1.3323e-15
  • % Verify that DCT-2 and DCT-3 are inverses of each other.
  • dct2 = dct(s,'Type',2);
  • idt2 = idct(s,'Type',3);
  • max(abs(dct2-idt2))
  • % ans = 4.4409e-16
  • dct3 = dct(s,'Type',3);
  • idt3 = idct(s,'Type',2);
  • max(abs(dct3-idt3))
  • % ans = 1.1102e-157 Z% Y6 N. r1 Q5 ]5 m
         $ s; U. E1 ^6 Z7 C! i5 j: R5 o5 _$ c

5 B' p( Y9 ?$ z5 u' |; i& z8 R. A* o/ Z7 e
  • TA的每日心情

    2019-11-29 15:37
  • 签到天数: 1 天

    [LV.1]初来乍到

    2#
    发表于 2019-12-27 18:28 | 只看该作者
    学习啦,谢谢分享
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-23 22:27 , Processed in 0.156250 second(s), 26 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表