Implementing Sobel Gradient without image package

9 ビュー (過去 30 日間)
scarlett05
scarlett05 2018 年 4 月 6 日
回答済み: Andrew Davies 2018 年 4 月 6 日
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, [])

回答 (1 件)

Andrew Davies
Andrew Davies 2018 年 4 月 6 日
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?

カテゴリ

Help Center および File ExchangeOctave についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by