Undefined function 'conv2' for input arguments of type 'double' and attributes 'full 3d complex'.

来源:互联网 发布:qq源码多少行 编辑:程序博客网 时间:2024/05/11 13:04

matlab提示错误:Undefined function 'conv2' for input arguments of type 'double' and attributes 'full 3d complex'.

 

原因:在matlab中,彩色图像的表示是三维矩阵,即(x,y,color)。但conv2函数只能对2维图像进行卷积操作,不能直接作用于三维矩阵。

 

三种解决方案:

No.1  使用n维卷积函数 convn()。

No.2  先使用rgb2gray()函数将三维彩色图像转换成灰度图像,然后再使用conv2()进行2维滤波操作。

           例:filter_F= conv2(gauss,rgb2gray(img_double));

No.3   对彩色(RGB)图像的每一层分别使用conv2()进行2维卷积操作。

           例:filter_F = zeros(size(im_double));

                   for i=1:3 

                            filter_F(:,:,i)= conv2(gauss, im_double(:,:,i);

                   end

2 0
原创粉丝点击