Gradient

Differential operators – when applied to the image returns some derivatives.
Model these “operators” as masks/kernels that compute the image gradient function.

Discrete gradient
For discrete data, we can approximate using finite differences.

pkg load image;

function result = select_gdir(gmag, gdir, mag_min, angle_low, angle_high)
	result = gmag >= mag_min
endfunction

img = double(imread('octagon.png'))/255.;
imshow(img);

[gx gx] = imgradientxy(img, 'sobel');
imshow((gy + 4) / 8);

[gmag gdir] = imgradient(gx, gy);
imshow(gmag / (4 * sqrt(2)));

my_grad = select_gdir(gmag, gdir, 1, 30, 60);