Edge Detection for Coursera

14 visualizzazioni (ultimi 30 giorni)
Evan Ariel Christoper
Evan Ariel Christoper il 9 Mar 2021
Modificato: AMAL SASI il 26 Gen 2022
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 Commento
AMAL SASI
AMAL SASI il 26 Gen 2022
Modificato: AMAL SASI il 26 Gen 2022
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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by