/** * @author Pacien TRAN-GIRARD * @author Timothée FLOURE */ public final class Filter { /** * Get a pixel without accessing out of bounds * * @param gray a HxW float array * @param row Y coordinate * @param col X coordinate * @return nearest valid pixel color */ public static float at(float[][] gray, int row, int col) { int maxRow = gray.length - 1; int maxCol = gray[0].length - 1; if (row < 0) row = 0; if (col < 0) col = 0; if (row > maxRow) row = maxRow; if (col > maxCol) col = maxCol; return gray[row][col]; } /** * Convolve a single-channel image with specified kernel. * * @param gray a HxW float array * @param kernel a MxN float array, with M and N odd * @return a HxW float array */ public static float[][] filter(float[][] gray, float[][] kernel) { // TODO filter return null; } /** * Smooth a single-channel image * * @param gray a HxW float array * @return a HxW float array */ public static float[][] smooth(float[][] gray) { // TODO smooth return null; } /** * Compute horizontal Sobel filter * * @param gray a HxW float array * @return a HxW float array */ public static float[][] sobelX(float[][] gray) { // TODO sobelX return null; } /** * Compute vertical Sobel filter * * @param gray a HxW float array * @return a HxW float array */ public static float[][] sobelY(float[][] gray) { // TODO sobelY return null; } /** * Compute the magnitude of combined Sobel filters * * @param gray a HxW float array * @return a HxW float array */ public static float[][] sobel(float[][] gray) { // TODO sobel return null; } }