线段的变化趋势与其傅里叶变换后图像关系

仅为自己的学习记录,本人比较懒,不写注释了。欢迎指出问题和提问!

import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft,ifft
from mpl_toolkits.mplot3d import Axes3D


def center(data,l):
    for i in range(l):
        for j in range(l):
            data[i][j] = pow(-1,i+j)*data[i][j]
    return data

def function(x):
    if x==0:
        return 1
    #elif x<4 and x>3:
    #    return 1
    else:
        return 0
if __name__ == '__main__':
    xs = np.linspace(-5,5,100)
    y = []
    for x in xs:
        y.append(function(x))
    yy = fft(y)
    yyreal = np.real(yy)
    yyimag = np.imag(yy)
    xx = np.linspace(0,100,100)
    fig = plt.figure()
    plt.subplot(334)
    yyreal = np.hstack((yyreal,yyreal))
    plt.plot(yyreal)
    plt.subplot(335)
    yyimag = np.hstack((yyimag,yyimag))
    plt.plot(yyimag)
    plt.subplot(331)
    #y = np.hstack((y,y))
    plt.plot(y)
    plt.subplot(336)
    ax = fig.gca()
    ax.plot(yyreal,yyimag)
    plt.subplot(337)
    ll = np.power(yyreal,2)+np.power(yyimag,2)
    plt.plot(ll)
    #plt.scatter(yyreal,yyimag)

    #plt.subplot(335)
    #ax1 = Axes3D(fig)
    #ax1.plot3D(yyreal,yyimag,xx)
    plt.show()

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值