Error using conv2 N-D arrays are not supported.

13 Ansichten (letzte 30 Tage)
Bara
Bara am 6 Jun. 2021
Kommentiert: Madhav am 5 Jan. 2023
I have an error using conv2, I don't know how to fix it. Please help, here I am using Matlab version R2020a.
error starting from line 5
I=imread('peppers.png');
lpf1=[1/16 1/8 1/16;1/8 1/4 1/8;1/16 1/8 1/16];
lpf2=[1/10 1/10 1/10;1/10 1/5 1/10;1/10 1/10 1/10];
lpf3=[1 1 1;1 1 1;1 1 1]/9;
J1=uint8(conv2(double(I),lpf1,'same'));
J2=uint8(conv2(double(I),lpf2,'same'));
J3=uint8(conv2(double(I),lpf3,'same'));
figure,imshow(I);
figure,imshow(J1);
figure,imshow(J2);
figure,imshow(J3);
-Thank you in advance

Akzeptierte Antwort

Stephen23
Stephen23 am 6 Jun. 2021
Perhaps you could use convn instead of conv2:
I = imread('peppers.png');
lpf1 = 1./[16,8,16;8,4,8;16,8,16];
lpf2 = 1./[10,10,10;10,5,10;10,10,10];
lpf3 = 1./[9,9,9;9,9,9;9,9,9];
J1 = uint8(convn(double(I),lpf1,'same'));
J2 = uint8(convn(double(I),lpf2,'same'));
J3 = uint8(convn(double(I),lpf3,'same'));
figure,imshow(I);
figure,imshow(J1);
figure,imshow(J2);
figure,imshow(J3);
  2 Kommentare
Bara
Bara am 6 Jun. 2021
thanks a lot, it worked in R2020a
Madhav
Madhav am 5 Jan. 2023
works perfect!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

HemanthKumar Maddipati
HemanthKumar Maddipati am 2 Apr. 2022
I have an error using filter2, I don't know how to fix it. Please help, here I am using Matlab version R2020a.
error in 3rd line
img=imread('image1.jpeg');
imshow(img)
Kaverage = filter2(fspecial('average',3),img)/255;
figure,
imshow(Kaverage)
Kmedian = medfilt2(img);
imshowpair(Kaverage,Kmedian,'montage')

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by