Exemplo n.º 1
0
 public PImage get(int index, int fg) {
   PImage msk = font[index];
   PImage img = pa.createImage(msk.width, msk.height, PConstants.RGB);
   msk.loadPixels();
   img.loadPixels();
   for (int i = 0; i < img.pixels.length; i++) {
     img.pixels[i] = fg;
   }
   img.mask(msk);
   return img;
 }
Exemplo n.º 2
0
 public PImage get(int index, int fg, int bg) {
   PImage msk = font[index];
   PImage img = pa.createImage(msk.width, msk.height, PConstants.RGB);
   msk.loadPixels();
   img.loadPixels();
   for (int i = 0; i < msk.pixels.length; i++) {
     if (msk.pixels[i] == Colors.WHITE) {
       img.pixels[i] = fg;
     } else {
       img.pixels[i] = bg;
     }
   }
   return img;
 }
Exemplo n.º 3
0
  public void display() {
    PImage img = kinect.getDepthImage();

    // PImage img = kinect.getVideoImage();
    // Being overly cautious here
    if (depth == null || img == null) return;

    // Going to rewrite the depth image to show which pixels are in threshold
    // A lot of this is redundant, but this is just for demonstration purposes
    display.loadPixels();
    for (int x = 0; x < kw; x++) {
      for (int y = 0; y < kh; y++) {
        // mirroring image
        int offset = kw - x - 1 + y * kw;
        // Raw depth
        int rawDepth = depth[offset];

        int pix = x + y * display.width;
        if (rawDepth < threshold) {
          // A red color instead
          display.pixels[pix] = p.color(150, 50, 50);
        } else {
          display.pixels[pix] = img.pixels[offset];
        }
      }
    }
    display.updatePixels();

    // Draw the image
    p.image(display, 0, 0);
  }
Exemplo n.º 4
0
 EImage(NoKinect sce, String file) {
   parent = sce;
   position = new int[3];
   extrude = parent.loadImage(file);
   extrude.loadPixels();
   forDelta = 10;
   values = new int[extrude.width * extrude.height];
   for (int x = forDelta; x < extrude.width; x += forDelta) {
     for (int y = forDelta; y < extrude.height; y += forDelta) {
       values[(x * extrude.width) + y] = (int) (parent.brightness((int) extrude.get(x, y)));
       for (int d = 0; d < forDelta; d++) {
         values[(x * extrude.width) + y] +=
             (int) (parent.brightness((int) extrude.get(x - d, y - d)));
       }
       values[(x * extrude.width) + y] /= forDelta;
     }
   }
 }
Exemplo n.º 5
0
  // Takes a PImage and compresses it into a JPEG byte stream
  // Adapted from Dan Shiffman's UDP Sender code
  public byte[] compressImage(PImage img) {
    // We need a buffered image to do the JPG encoding
    BufferedImage bimg = new BufferedImage(img.width, img.height, BufferedImage.TYPE_INT_RGB);

    img.loadPixels();
    bimg.setRGB(0, 0, img.width, img.height, img.pixels, 0, img.width);

    // Need these output streams to get image as bytes for UDP communication
    ByteArrayOutputStream baStream = new ByteArrayOutputStream();
    BufferedOutputStream bos = new BufferedOutputStream(baStream);

    // Turn the BufferedImage into a JPG and put it in the BufferedOutputStream
    // Requires try/catch
    try {
      ImageIO.write(bimg, "jpg", bos);
    } catch (IOException e) {
      e.printStackTrace();
    }

    // Get the byte array, which we will send out via UDP!
    return baStream.toByteArray();
  }
Exemplo n.º 6
0
  public void draw() {
    img.loadPixels();
    colorMode(HSB, 1, 1, 1);

    // for(int i = 0; i < settings.passesperupdate; i++ ){
    initBuckets();
    runBuckets();
    // }

    totalphotonscast = 0;

    // settings.exposure = (float) mouseX / 100;

    colorMode(RGB, 1);
    for (int x = 0; x < w; x++) {
      for (int y = 0; y < h; y++) {
        double div = count[x + y * h] / settings.exposure;
        totalphotonscast += count[x + y * h];
        int i = (x + y * w) * 3;
        int c = 0;
        if (mousePressed && mouseButton == LEFT) {
          // show grayscale, so early color renders dont look like shit
          c = color((float) ((plate[i + 0] + plate[i + 1] + plate[i + 2]) / div / 3));
        } else { // show color
          c =
              color(
                  (float) (plate[i + 0] / div),
                  (float) (plate[i + 1] / div),
                  (float) (plate[i + 2] / div));
        }
        img.pixels[x + y * w] = c;
      }
    }

    img.updatePixels();
    image(img, 0, 0, (float) (w * settings.scale), (float) (h * settings.scale));

    println(
        "Ms: "
            + (millis() - millis)
            + " - Pass: "******" - "
            + totalphotonscast
            + " rays cast so far - "
            + (totalphotonscast - lastphotonscast) / (millis() - millis) * 1000
            + " rays per second.");
    millis = millis();
    lastphotonscast = totalphotonscast;
    // if( frameCount % 1 == 0 ){
    if (keyPressed) {
      savedframecount += 1;
      saveFrame("out2/" + savedframecount + "_box.tiff");
      println("Saved a frame.");
      // wipePlate();
    }

    if (mousePressed && mouseButton == RIGHT) {
      FilmGraph.DrawGraph(this);
    }
  }