What is the meaning of this error (Using function medfilt2)
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi I am using medfilt2 function but the error below is generated. May I know what is the problem here ?
TIA
---------------------------
I = imread('Moon.jpg');
J = imnoise(I, 'salt & pepper', 0.15);
L = medfilt2(J, [3 3]);
subplot(1,3,1); imshow(I); title('input image')
subplot(1,3,2); imshow(J); title('noisy image')
subplot(1,3,3); imshow(L); title('noisy image')
??? Error using ==> iptcheckinput
Function ORDFILT2 expected its first input, A, to be
two-dimensional.
Error in ==> ordfilt2>ParseInputs at 135
iptcheckinput(A, {'numeric','logical'},
{'2d','real'}, mfilename, 'A', 1);
Error in ==> ordfilt2 at 51
[A,order,domain,s,padopt,msg] =
ParseInputs(varargin{:});
Error in ==> medfilt2 at 53
b = ordfilt2(a, order, domain, padopt);
0 commentaires
Réponses (3)
Wayne King
le 19 Juil 2014
Modifié(e) : Wayne King
le 19 Juil 2014
You're likely trying to input a RGB image (3-D) to medfilt2. If you enter
size(J)
what is returned?
If the last number is 3, then that is a RGB image.
You can use rgb2gray to turn J into a 2-D matrix suitable for medfilt2
0 commentaires
Image Analyst
le 20 Juil 2014
When I use standard demo image moon.tif (which is grayscale) instead of moon.jpg, it works fine. Try your demo with that standard image - it's probably using some image you go that was saved as RGB. By the way, your last title should read
title('Denoised Image')
0 commentaires
Ramzan Shahid khan
le 20 Fév 2020
image J is in RGB of 3-D matrix but medfit2 takes 2-D. So first convert the J image into 2-D with rgb2gray(J) function, then it will work fine.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!