2D解卷积在Matlab使用问题FFT [英] 2D Deconvolution using FFT in Matlab Problems

查看:271
本文介绍了2D解卷积在Matlab使用问题FFT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经错综复杂我在MATLAB中创建了一个二维高斯函数的图像,我也曾在MATLAB定义,现在我试图去卷积产生的矩阵来看看,如果我得到的二维高斯函数回使用FFT2和ifft2命令。不过,我得到结果的矩阵是不正确的(据我所知)。这里是code什么我迄今完成:

I have convoluted an image I created in matlab with a 2D Gaussian function which I have also defined in matlab and now I am trying to deconvolve the resultant matrix to see if I get the 2D Gaussian function back using the fft2 and ifft2 commands. However the matrix I get as a result is incorrect (to my knowledge). Here is the code for what I have done thus far:

%code对输入图像(IMG)[300x300的阵列]

% Code for input image (img) [300x300 array]

N = 100;
t = linspace(0,2*pi,50);
r = (N-10)/2;
circle = poly2mask(r*cos(t)+N/2+0.5, r*sin(t)+N/2+0.5,N,N);
img = repmat(circle,3,3);

%code二维高斯函数与C = 0 = SIG 1/64(Z)[300x300的阵列]

% Code for 2D Gaussian Function with c = 0 sig = 1/64 (Z) [300x300 array]

x = linspace(-3,3,300);
y = x';
[X Y] = meshgrid(x,y);
Z = exp(-((X.^2)+(Y.^2))/(2*1/64));

%code与Z(C)IMG的二维卷积[599x599阵列]

% Code for 2D Convolution of img with Z (C) [599x599 array]

C = conv2(img,Z);

%,我已经测试了这个卷积是正确使用IMG和C截面形状向量,所得到的x-y图是我从卷积期待。

% I have tested that this convolution is correct using cross section profile vectors for img and C and the resulting x-y plots are what i expect from the convolution.

%由我的卷积的知识,该算法可以作为在傅立叶空间中一乘法器,因此除以我的输入(IMG)的傅立叶变换我的输出(卷积图像)的我应找回点s $ P $垫函数(Z - 2D高斯函数)。傅立叶逆变换后施加到这个结果由分割

% From my knowledge of convolution, the algorithm works as a multiplier in Fourier space, therefore by dividing the Fourier transform of my output (convoluted image) by my input (img) I should get back the point spread function (Z - 2D Gaussian function) after the inverse Fourier transform is applied to this result by division.

%code企图2D卷积

% Code for attempted 2D deconvolution

Fimg = fft2(img,599,599);

%零填充以增加结果599x599阵列

% zero padding added to increase result to 599x599 array

FC = fft2(C);
R = FC/Fimg;

%现在我得到这个错误提示:警告:矩阵接近奇异或严重缩放。结果可能不准确。 RCOND = 2.551432e-22

% I now get this error prompt: Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.551432e-22

iFR = ifft2(R);

我期待IFR接近到Z,但我得到的东西完全不同。这可能是复杂的值Z的近似值,但我似乎无法检查它,因为我不知道如何绘制在Matlab三维复杂矩阵。因此,如果任何人都可以告诉我,我的答案是否正确或不正确的,以及如何得到这个反褶积工作?我一定会觉得很AP preciated。

I'm expecting iFR to be close to Z but I'm getting something completely different. It may be an approximation of Z with complex values but I can't seem to check it since I don't know how to plot a 3D complex matrix in matlab. So if anyone can tell me whether my answer is correct or incorrect and how to get this deconvolution to work? I'd be much appreciated.

推荐答案

R = FC / Fimg 必须 R = FC./Fimg ; 你需要做的分裂元素明智

R = FC/Fimg needs to be R = FC./Fimg; You need to do division element-wise.

这篇关于2D解卷积在Matlab使用问题FFT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆