필터 지우기
필터 지우기

Implementing Sobel Gradient without image package

조회 수: 6 (최근 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 CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by