How to convolve an image with a 2D function and plot the result
显示 更早的评论
Hi, I have a bar phantom image attached that I want to convolve with the 2d function h1(x,y)=e^(-5x^2-5y^2). I'm not very familiar with Matlab or similar programs so bear with me.
I have created and plotted the function h1 using the following code:
x = [-1: .01: 1];
y = [-1: .01: 1];
[x_,y_] = meshgrid(x,y);
h1_ = exp((-5.*x_.^2)-(5.*y_.^2));
surf(x_,y_,h1_)
I then inserted the bar phantom image into Matlab using:
I = imread('bar phantom1.png');
From here I'm stuck and I've tried a number of things unsuccessfully. I've tried:
H1_ = abs(fft2(h1_));
I1 = abs(fft2(I));
g = ifft2(H1_.*I1);
And get the error: Array dimensions must match for binary array op.
I tried changing the dimensions of my x and y variables to match the dimensions of my image but the result g is a blank white image.
I also played tried to avoid using fft2 using imfilter, double, and conv2 but only got all white or black resulting images. Any help would be greatly appreciated.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!