Edge Detection for Coursera
조회 수: 14 (최근 30일)
이전 댓글 표시
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
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 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!