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

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 Exchange에서 Images에 대해 자세히 알아보기

질문:

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