Fermenting Data: Aarhus City Wide Data Exhibition
17/09/21—16/10/2021

JAR

JAR java archive repository. This JAR contains digital bodies of code and data. Here follows the source code:

// Dithering images import java.io.File; import java.io.IOException; import java.awt.image.BufferedImage; import java.awt.Color; import javax.imageio.ImageIO; // import java.lang.*; import java.lang.Math; public class DitherClass { public static void main(String args[])throws IOException { // get the file path String filePath = new File("").getAbsolutePath(); filePath.concat("path to the property file"); // BufferedImage for source image BufferedImage srcImg = null; File f = null; // Read source image file try { f = new File(filePath + "/bigCab.jpg"); srcImg = ImageIO.read(f); } catch(IOException e) { System.out.println("Error: " + e); } // Get source image dimension int width = srcImg.getWidth(); int height = srcImg.getHeight(); // testing functions float weightings[] = { 0.3f, 0.59f, 0.11f }; BufferedImage resultImg = luminance(weightings, width, height, srcImg); DitherNeighbors neighbors = new DitherNeighbors(); BufferedImage atkinImg = atkinson( width, height, resultImg, neighbors ); // save Dither img try { f = new File(filePath + "/bigCabOut.png"); ImageIO.write(atkinImg, "png", f); } catch(IOException e) { System.out.println("Error: " + e); } } //////////////////////// // Atkinson threshold private static int threshold(int lum) { if (lum < 128) { return 0; } else { return 255; } } //////////////////////// // Atkinson luminance private static BufferedImage luminance( float[] weightings, int width, int height, BufferedImage srcImg ) { if (weightings.length == 0) { weightings[0] = 0.3f; weightings[1] = 0.59f; weightings[2] = 0.11f; } BufferedImage lumImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int p = srcImg.getRGB(x, y); // int a = (p >> 24) & 0xff; int r = (p >> 16) & 0xff; int g = (p >> 8) & 0xff; int b = p & 0xff; int result = Math.round( r * weightings[0] + g * weightings[1] + b * weightings[2] ); Color color = new Color(result, result, result); lumImg.setRGB(x, y, color.getRGB()); } } return lumImg; }

Fermenting Data Aarhus More info here
17/09/21—16/10/2021

JAR

//////////////////////// // Atkinson luminance private static BufferedImage atkinson( int width, int height, BufferedImage lumImg, DitherNeighbors neighbours ) { int mono; int diff; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int p = lumImg.getRGB(x, y); int blue = p & 0xff; mono = threshold(blue); diff = blue - mono; // set current pixel Color newColor = new Color(mono, mono, mono); lumImg.setRGB(x, y, newColor.getRGB()); int spread = (int) Math.floor(diff / 8); for (var j = 0; j < neighbours.pos.length; j++) { int xOffset = neighbours.pos[j].getX(); int yOffset = neighbours.pos[j].getY(); int xall = x + xOffset; int yall = y + yOffset; // check for out of bounds! if (x + xOffset >= width || x + xOffset < 0 || y + yOffset >= height || y + yOffset < 0 ) { break; } int getColor = lumImg.getRGB(xall, yall); int bb = getColor & 0xff; int newVal = bb + spread; lumImg.setRGB(xall, yall, newVal); } } } return lumImg; } } public class DitherNeighbors { public Coord[] pos = new Coord[6]; DitherNeighbors() { // defining neighbors pos[0] = new Coord(1, 0); pos[1] = new Coord(2, 0); pos[2] = new Coord(-1, 1); pos[3] = new Coord(0, 1); pos[4] = new Coord(1, 1); pos[5] = new Coord(0, 2); } public static void main(String args[]){ System.out.println("DitherNeighbors run"); } public int[] getPos(int index) { int[] retObj = { -999, -999 }; retObj[0] = pos[index].x; retObj[1] = pos[index].y; return retObj; }}