From c777a9841e5af653b2dd1ebb6665df9dbb31a214 Mon Sep 17 00:00:00 2001 From: Avatar Date: Thu, 25 Feb 2016 15:14:20 +0700 Subject: [PATCH] Delete NewClass.java --- src/image2d/NewClass.java | 97 --------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 src/image2d/NewClass.java diff --git a/src/image2d/NewClass.java b/src/image2d/NewClass.java deleted file mode 100644 index 831150a..0000000 --- a/src/image2d/NewClass.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package image2d; - -/** - * - * @author pratchaya - */ -public class NewClass { - - int[] input; - int[] output; - float[] template = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; - ; - int progress; - int templateSize = 3; - int width; - int height; - double[] direction; - - public void sobel() { - progress = 0; - } - - public void init(int[] original, int widthIn, int heightIn) { - width = widthIn; - height = heightIn; - input = new int[width * height]; - output = new int[width * height]; - direction = new double[width * height]; - input = original; - } - - public int[] process() { - float[] GY = new float[width * height]; - float[] GX = new float[width * height]; - int[] total = new int[width * height]; - progress = 0; - int sum = 0; - int max = 0; - - for (int x = (templateSize - 1) / 2; x < width - (templateSize + 1) / 2; x++) { - progress++; - for (int y = (templateSize - 1) / 2; y < height - (templateSize + 1) / 2; y++) { - sum = 0; - - for (int x1 = 0; x1 < templateSize; x1++) { - for (int y1 = 0; y1 < templateSize; y1++) { - int x2 = (x - (templateSize - 1) / 2 + x1); - int y2 = (y - (templateSize - 1) / 2 + y1); - float value = (input[y2 * width + x2] & 0xff) * (template[y1 * templateSize + x1]); - sum += value; - } - } - GY[y * width + x] = sum; - for (int x1 = 0; x1 < templateSize; x1++) { - for (int y1 = 0; y1 < templateSize; y1++) { - int x2 = (x - (templateSize - 1) / 2 + x1); - int y2 = (y - (templateSize - 1) / 2 + y1); - float value = (input[y2 * width + x2] & 0xff) * (template[x1 * templateSize + y1]); - sum += value; - } - } - GX[y * width + x] = sum; - - } - } - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - total[y * width + x] = (int) Math.sqrt(GX[y * width + x] * GX[y * width + x] + GY[y * width + x] * GY[y * width + x]); - direction[y * width + x] = Math.atan2(GX[y * width + x], GY[y * width + x]); - if (max < total[y * width + x]) { - max = total[y * width + x]; - } - } - } - float ratio = (float) max / 255; - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - sum = (int) (total[y * width + x] / ratio); - output[y * width + x] = 0xff000000 | ((int) sum << 16 | (int) sum << 8 | (int) sum); - } - } - progress = width; - return output; - } - - public double[] getDirection() { - return direction; - } - - public int getProgress() { - return progress; - } -}