Edge Detection for Coursera

14 次查看(过去 30 天)
Evan Ariel Christoper
编辑: AMAL SASI 2022-1-26
Im trying to finish my "Mastering Programming for Matlab" on coursera, but im stuck on this question
Here are my code
function edg = edgy(pict)
test = double(pict);
sx = [-1 0 1; -2 0 2; -1 0 1];
sy = [ 1 2 1; 0 0 0; -1 -2 -1];
edg = zeros((size(test,1)-2),(size(test,2)-2));
for ii = 2:(size(test,1)-1)
for jj = 2:(size(test,2)-1)
A = test((ii-1):(ii+1),(jj-1):(jj+1));
x = sx.*A;
x_sum = sum(sum(x));
y = sy.*A;
y_sum = sum(sum(y));
M = sqrt(x_sum^2 + y_sum^2);
edg(ii,jj) = M;
end
end
edg = uint8(edg(1:end-1, 1:end-1));
end
And this is my output
But this is what i get when i submit it
What should i do? I have no clue ._.
  1 个评论
AMAL SASI
AMAL SASI 2022-1-26
编辑:AMAL SASI 2022-1-26
function edg = edgy(pict)
test = double(pict);
size(pict)
sx = [-1 0 1; -2 0 2; -1 0 1];
sy = [ 1 2 1; 0 0 0; -1 -2 -1];
edg = zeros((size(test,1)-2),(size(test,2)-2));
for ii = 2:(size(test,1)-1)
for jj = 2:(size(test,2)-1)
A = test((ii-1):(ii+1),(jj-1):(jj+1));
x = sx.*A;
x_sum = sum(sum(x));
y = sy.*A;
y_sum = sum(sum(y));
M = sqrt(x_sum^2 + y_sum^2);
edg(ii-1,jj-1) = M;
end
end
edg = uint8(edg);
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile 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!

Translated by