conv2: First and second arguments must be numeric or logical

5 vues (au cours des 30 derniers jours)
Ryan Constantine
Ryan Constantine le 6 Oct 2020
Commenté : Ameer Hamza le 6 Oct 2020
I continue to get the same issue although I have two matrices using only integers.
h1 = {-1, -2, -1; 0, 0, 0; 1, 2, 1};
ogI = imread('image.jpeg');
I = rgb2gray(ogI);
I1 = conv2(I, h1, 'same');
imshow(I1);
Even if I set 'I' to a single or double inside of the function it does not work. This may be trivial but anything would help, thank you.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 6 Oct 2020
Modifié(e) : Ameer Hamza le 6 Oct 2020
You are defining h1 as a cell array. Define it as a numeric array
h1 = [-1, -2, -1; 0, 0, 0; 1, 2, 1]; % use square brackets
  2 commentaires
Ryan Constantine
Ryan Constantine le 6 Oct 2020
Thank you! It was trivial. facepalm
Ameer Hamza
Ameer Hamza le 6 Oct 2020
I am glad to be of help!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by