Edge Detection for Coursera

14 vues (au cours des 30 derniers jours)
Evan Ariel Christoper
Evan Ariel Christoper le 9 Mar 2021
Modifié(e) : AMAL SASI le 26 Jan 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 commentaire
AMAL SASI
AMAL SASI le 26 Jan 2022
Modifié(e) : AMAL SASI le 26 Jan 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by