Implementing Sobel Gradient without image package

10 visualizaciones (últimos 30 días)
scarlett05
scarlett05 el 6 de Abr. de 2018
Respondida: Andrew Davies el 6 de Abr. de 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, [])

Respuestas (1)

Andrew Davies
Andrew Davies el 6 de Abr. de 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?

Categorías

Más información sobre Octave en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by