Syslab图像低通滤波 BoundsError

using TyMath

using TyPlot

using TyImages

using TyDSPSystem

path = "Lena.bmp"

img = imread(path)

img_gray = rgb2gray(img)

h,w=size(img_gray)

DFTI=fftshift(fft(img_gray))

cf=30

h= round(Int, h/2)

w= round(Int, w/2)

cf = round(Int, cf)

LDFTI=zeros(Int,(h,w))

LDFTI[h-cf:h+cf,w-cf:w+cf].=DFTI[h-cf:h+cf,w-cf:w+cf]

g=(abs.(ifft(ifftshift(LDFTI))))

grayOut2=UInt8.(round.(g))

subplot(131)

imshow(img)

title("原图")

subplot(132)

imshow(grayOut2)

title("低通滤波")

returns

BoundsError: attempt to access 256×256 Matrix{Int64} at index [226:286, 226:286]

就是字面意思

LDFTI[h-cf:h+cf,w-cf:w+cf].=DFTI[h-cf:h+cf,w-cf:w+cf]

这一行中括号里面的index比LDFTI数组尺寸都大了。你需要好好检查index的计算方式