for i=1:size(C,1)-2 for j=1:size(C,2)-2 %Sobel mask for x-direction: Gx=((2*C(i+2,j+1)+C(i+2,j)+C(i+2,j+2))-(2*C(i,j+1)+C(i,j)+C(i,j+2))); %Sobel mask for y-direction: Gy=((2*C(i+1,j+2)+C(i,j+2)+C(i+2,j+2))-(2*C(i+1,j)+C(i,j)+C(i+2,j)));sir i'm not able to understand dis part.can u explain it with example?suppose C is 3x3 size array then what could be value of j.

Thats really awesome code you have!!! But I have a question, so i am trying to manipulate or modify an image using the sobel filter along a slider in GUI. So, can you maybe explain a little bit about how you can link the sobel filter to the slider?

@Sheldon CooperThat line is the convolution between Sobel 3x3 horizontal mask and the image matrix. Let's say we consider the element C(i,j) from the original image matrix. To calculate the coresponding element in Gx matrix, Gx(i,j), we take the 8 neighbours surrounding the element C(i,j) and C(i,j), we multiply each of them with the coresponding element of the Sobel mask, and we sum these multiplications: Gx(i,j)=C(i-1,j-1)*S(1,1)+C(i-1,j)*S(1,2)*C(i-1,j+1)*S(1,3)+... (9 multiplications).

I found in a journal that use sobel approximation with a threshold value of 0.02 for obtain edge map. How to get that threshold ? because as I know, I only can use threshold with range 0 - 255 (based on maximum gray value) from sobel detection.