int D1, D2; int X, Y; int c1x, c1y, c2x, c2y; int DOTS = 180; //multiple of 3 here //determines requantization int grayValues = 256; float[] map = new float[DOTS]; int[] xi = new int[grayValues]; int[] hist = new int[grayValues]; PImage a, b; void setup() { c1x = 88; c1y = 256-88; c2x = 128; c2y = 128; background(200); stroke(0,0,0); size(300, 420); colorMode(RGB, width); framerate(5); a = loadImage("lena.jpg"); image(a, 0, 0); loadPixels(); b = loadImage("lena.jpg"); } void draw() { updatePixels(); //background(255, 255, 255); if (mousePressed == true) { X = mouseX; Y = mouseY; // selezione del punto che si modifica D1 = (X - c1x)*(X - c1x) + (Y - c1y)*(Y - c1y); D2 = (X - c2x)*(X - c2x) + (Y - c2y)*(Y - c2y); if (D1 < D2) { c1x = X; c1y = Y; } else { c2x = X; c2y = Y; } } stroke(250,0,0); strokeWeight(1); //curve(0, 255, 0, 255, c1x, c1y, 255, 0); //curve(0, 255, c1x, c1y, 255, 0, 255, 0); beginShape(LINE_STRIP); curveVertex(0, 255); curveVertex(0, 255); curveVertex(c1x, c1y); curveVertex(c2x, c2y); curveVertex(255, 0); curveVertex(255, 0); endShape(); ellipseMode(CENTER); int steps = DOTS/3; int k = 0; for (int i = 0; i < steps; i++) { float t = i / float(steps); float x = curvePoint(0, 0, c1x, c2x, t); float y = curvePoint(255, 255, c1y, c2y, t); ellipse(x, y, 5, 5); map[i] = 255 - y; while ((k < floor(x)) &&(k maxval) { maxval = hist[i]; } } // Normalize the histogram to values between 0 and "height" for (int i=0; i