當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python scipy.fft.idctn()用法及代碼示例

借助於scipy.fft.idctn()方法,我們可以通過選擇不同類型的序列來計算多維離散餘弦變換的逆值,並使用此方法返回變換後的數組。

用法:

scipy.fft.idctn(x, type=2)

返回值:它將返回轉換後的數組。

範例1:在此示例中,我們可以看到,通過使用scipy.fft.idctn()方法,我們可以通過默認選擇不同類型的序列來獲得多維離散餘弦變換的逆函數(即2)。

Python3



# import scipy and numpy 
from scipy import fft 
import numpy as np 
  
array_gfg = np.random.randn(3, 3) 
  
# Using scipy.fft.idctn() method 
gfg = fft.idctn(array_gfg) 
  
print(gfg)

輸出:

[[-0.27264259  0.12356192  0.12133914]
 [ 0.00835797  0.11993761 -0.12110712]
 [ 0.09770593 -0.14543749 -0.01109258]]

範例2:

Python3

# import scipy and numpy 
from scipy import fft 
import numpy as np 
  
array_gfg = np.random.randn(4, 2) 
  
# Using scipy.fft.idctn() method 
gfg = fft.idctn(array_gfg, 4) 
  
print(gfg)

輸出:

[[ 0.1430296   0.09689253]
 [ 0.00632705  0.24546606]
 [-0.26553743  0.01931002]
 [-0.07106229 -0.02292552]]

相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python – scipy.fft.idctn() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。