Edge Detection for Coursera

14 ビュー (過去 30 日間)
Evan Ariel Christoper
Evan Ariel Christoper 2021 年 3 月 9 日
編集済み: 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 Center および File ExchangeIntroduction 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