MATLAB: Matrix dimensions must agree

image denoisingImage Processing Toolbox

i used the builtin Matlab function weiner2 and did the example below… it was an example in the document of weiner function… but i get the below error… please can someone help me rectify it…
RGB = imread('saturn.png');
I = rgb2gray(RGB);
J = imnoise(I,'gaussian',0,0.025);
K = wiener2(J,[5 5]);
figure, imshow(K)
??? Error using ==> minus
Matrix dimensions must agree.
Error in ==> wiener2 at 71
f = g - localMean;

Best Answer

Please give the entire error message, not just a small part snipped out like you did.
The code works just fine for me. I don't get that error.
Related Question