#include
#include
#include
int main() {
int i, j;
array double g[3][3]={{-1,0,1},{-2,0,2},{-1,0,1}};
array double x[16], y[16], z1[256], f[16][16], H[18][18], V[18][18],Z[18][18], Z1[256];
linspace(x,0,16);
linspace(y,0,16);
for(i=3; i<13; i++)
for(j=3; j<13; j++) {
z1[i*16+j]=1;
f[i][j] = 1;
}
plotxyz(x,y,z1); /* original image */
conv2(H,f,g);
conv2(V,f,transpose(g));
Z = H .* H + V .* V; /* magnitude of the pixel value */
for(i = 0; i<16; i++)
for(j=0; j<16; j++)
Z1[i*16+j] = Z[i+1][j+1];
plotxyz(x,y,Z1); /* edge finded image */
}