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!
