void setup(){ int imWidth = 352; int imHeight = 288; int cAmt = imWidth*imHeight; size(imWidth, imHeight); //noLoop(); } String lines[] = loadStrings("http://imagine-it.org/cs576/args.txt"); int loadStage = 0; String cmd = lines[0]; String cmdList[] = split(cmd); String imFilename = cmdList[0]; int imWidth = 352; int imHeight = 288; int qLevel = int(cmdList[1]); int numCoeff = int(cmdList[2]); int cAmt = imWidth*imHeight; int[] rs = new int[cAmt]; int[] gs = new int[cAmt]; int[] bs = new int[cAmt]; int N = 8; int bX=0; int zigZag[] = {1,2,6,7,15,16,28,29,3,5,8,14,17,27,30,43,4,9,13,18,26,31,42,44,10,12,19,25,32,41,45,54,11,20,24,33,40,46,53,55,21,23,34,39,47,52,56,61,22,35,38,48,51,57,60,62,36,37,49,50,58,59,63,64}; float[] rCoeffBuffer = new float[N*N]; float[] gCoeffBuffer = new float[N*N]; float[] bCoeffBuffer = new float[N*N]; int[] channelNew = new int[imWidth*imHeight]; int blocksW = imWidth/N; int blocksH = imHeight/N; void draw(){ if(loadStage==0){ fill(0,0,0); rect(0,0, imWidth, imHeight); fill(204, 102, 0); PFont font; font = loadFont("Alba-18.vlw"); textFont(font, 18); text( ("Type 'y' if you want to DCT " + imFilename + "\nwith quantization " + qLevel + " and " + numCoeff + " coefficients"), 20, 100); } else if(loadStage==1){ // open a file and read its binary data byte b[] = loadBytes(imFilename); // get each value, from 0 to 255 for (int i = 0; i < cAmt; i++) { int a = b[i] & 0xff; rs[i]= a; } for (int i = cAmt; i < (cAmt*2); i++) { int a = b[i] & 0xff; gs[i-cAmt]= a; } for (int i = (cAmt*2); i < (cAmt*3); i++) { int a = b[i] & 0xff; bs[i-(cAmt*2)]= a; } println("Done reading image in"); fill(0,0,0); rect(0,0, imWidth, imHeight); fill(204, 102, 0); PFont font; font = loadFont("Alba-18.vlw"); textFont(font, 18); text( ( imFilename + " is loaded, \n now computing DCT"), 100, 100); println(blocksW); println(blocksH); loadStage=2; } else if(loadStage==2){ if( bX