Добрый день. Есть массив яркости, необходимо сформировать из него новое изображение.
Код | public class test { public static void main(String[] args) throws IOException { BufferedImage img = ImageIO.read(new File("img.bmp")); int w = img.getWidth(); int h = img.getHeight(); int g_max = 255, g_min = 1; int[] img_input = new int[w*h]; int[] img_output = new int[w*h];
double input, output; int i = 0; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { input = img.getData().getSample(x, y, 0); output = Math.abs(input - ((g_max - g_min) * (input/(w * h)) + g_min)); img_input[i] = (int)input; img_output[i] = (int)output; i++; } } int j = 0; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { System.out.println(" input: "+ + img_input[j] + " ouput: " + img_output[j]); j++; } } //BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_USHORT_GRAY); //ImageIO.write(bi, "bmp", new File("image.bmp")); } }
|
Как это сделать? Если можно, то пример, пожалуйста. Изображение полутоновое. |