Implementing Sobel Gradient without image package

1 vue (au cours des 30 derniers jours)
scarlett05
scarlett05 le 6 Avr 2018
I am supposed to apply a Sobel filter on an image in Octave, but I am not allowed to use any functions from the image package. I wrote the code but my output is just a black image. Here is what I have so far: (Thank you in advance!)
kx= [1 ,0 ,-1; 2,0,-2; 1, 0 ,-1];
ky= [1,2,1; 0,0, 0; -1, -2 ,-1];
H = conv2(kx,im2double(my_img),'same');
V = conv2(ky,im2double(my_img),'same');
E = sqrtm(H.*H + V.*V);
figure 4
imshow(E, [])

Réponses (1)

Andrew Davies
Andrew Davies le 6 Avr 2018
kx= [1 ,0 ,-1; 2,0,-2; 1, 0 ,-1];
ky= [1,2,1; 0,0, 0; -1, -2 ,-1];
H = conv2(im2double(my_img),kx,'same');
V = conv2(im2double(my_img),ky,'same');
E = sqrt(H.*H + V.*V);
imshow(E, [])
conv2(... 'same') uses the size of the first input. Also don't you want sqrt and not sqrtm?

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by