Question
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);
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 24, 2026
Perhaps you could use convn instead of conv2:
I = imread('peppers.webp');
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);

figure,imshow(J1);

figure,imshow(J2);

figure,imshow(J3);

100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related convolution Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →