Undefined function 'padarray' for input arguments of type 'uint8'.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2020-6-12
>> 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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
