fix the error? ??? Undefined function or method 'conv2' for input arguments of type 'double' and attributes 'full 3d complex'.

clear all;
close all;
clc;
I=imread('pic.jpg');
imshow(I);
%%Gabor
phi = 6*pi/8;
theta = 2;
sigma = 0.65*theta;
filterSize = 5;
G = zeros(filterSize);
for i=(0:filterSize-1)/filterSize
for j=(0:filterSize-1)/filterSize
xprime= j*cos(phi);
yprime= i*sin(phi);
K = exp(2*pi*theta*sqrt(-1)*(xprime+ yprime));
G(round((i+1)*filterSize),round((j+1)*filterSize)) = exp(-(i^2+j^2)/(sigma^2))*K;
end
end
%%Convolve
J = conv2(I,G);
figure, imshow(imag(J));

 採用された回答

Wayne King
Wayne King 2013 年 5 月 30 日
編集済み: Wayne King 2013 年 5 月 30 日
I'm sure the problem is coming from the fact that your input I is 3-D. What would you expect 2-D convolution to do with a 3-D array and a 2-D matrix (your G)
How about doing this?
I = imread('pic.jpg');
I = double(rgb2gray(I)); % if you have the Image Processing Toolbox
Then try
J = conv2(I,G);

1 件のコメント

saipb
saipb 2019 年 11 月 21 日
Wayne,
How does the above solution take care of the fact that a 2-D convolution is being performed with a 3-D array and a 2-D matrix? It only takes care of the the data type being double. Isn't it? I am also interested in performing a 2-D Gaussian filter, however, because I use meshgrid and compute the Gaussian using x and y which are now 3D variables, even my 2D filter will turn out to be 3D. In such a scenario, is it possible to use conv2(u,G_xy) or should I just go with convn(u,G_xy)?
-Sai

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

質問済み:

2013 年 5 月 30 日

コメント済み:

2019 年 11 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by