Undefined function 'padarray' for input arguments of type 'uint8'.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am doing the MATLAB for beginners in Coursera. I am supposed to blur the image provided. The code works when run in my PC but I am getting this error message on the assignment page.
Undefined function 'padarray' for input arguments of type 'uint8'.
Error in blur (line 3)
img_padded = padarray(img,[w w],0,'both');
function output = blur(img,w)
img = uint8(img);
img_padded = padarray(img,[w w],0,'both');
[row, col] = size(img_padded);
blurred = zeros (row, col);
for ii = (1+w):(row-w)
for jj = (1+w):(col-w)
submatrix = zeros(2*w + 1, 2*w + 1);
for kk = (ii-w):(ii+w)
for ll = (jj-w):(jj+w)
submatrix (kk,ll) = img_padded (kk,ll);
end
end
blurred (ii,jj) = sum (submatrix, 'all')/((2*w+1)^2);
end
end
output = blurred (w+1:row-w,w+1:col-w);
output = uint8(output);
end
3 commentaires
Walter Roberson
le 12 Juin 2020
>> blur(ones(10,10),3)
ans =
10×10 uint8 matrix
0 0 0 1 1 1 1 0 0 0
0 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 0
0 0 0 1 1 1 1 0 0 0
It seems unlikely that an image that is all 1 should get blurred into something that contains some 0's.
However, you did not post the problem statement of what is to happen at the boundaries.
Réponses (0)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
