Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { public static double[] sobelKernel(int length, int size) { if (size <= 0) { return null; } double[] sobelKernel = new double[length]; Arrays.fill(sobelKernel, 0); for (int i = 1; i <= size; i++) { sobelKernel[length - i] = -i; sobelKernel[i] = i; } return sobelKernel; } }