Implementing Sobel Gradient without image package
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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, [])
0 Kommentare
Antworten (1)
Andrew Davies
am 6 Apr. 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?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Octave finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!