Package processing.core

Examples of processing.core.PImage


   * @param nbrImages in the range 1 - 3
   */
  public void setImages(String imgFile, int nbrImages){
    nbrImages = PApplet.constrain(nbrImages, 1, 3);
    if(imgFile != null && nbrImages > 0){
      PImage img = winApp.loadImage(imgFile);
      if(img == null){
        if(G4P.messages) System.out.println("Can't find button image file");
      }
      else
        setImages(img, nbrImages);
View Full Code Here


   */
  public void setImages(PImage img, int nbrImages){
    if(img != null && nbrImages > 0){
      int iw = img.width / nbrImages;
      for(int i = 0; i < nbrImages;  i++){
        bimage[i] = new PImage(iw, img.height, ARGB);
        bimage[i].copy(img,
            i * iw, 0, iw, img.height,
            0, 0, iw, img.height);
      }
      for(int i = nbrImages; i < 3; i++){
View Full Code Here

  }

 
  private static void makePalettes(){
    // Load the image
    PImage image = null;;
    InputStream is = app.createInput("user_gui_palette.png");
    if(is != null){
      try {
        is.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
      image = app.loadImage("user_gui_palette.png");
      GMessenger.message(USER_COL_SCHEME, null, null);
    }
    else {
      // User image not provided
      image = app.loadImage("default_gui_palette.png");
    }
    // Now make the palletes
    palettes = new int[16][16];
    jpalettes = new Color[16][16];
    for(int p = 0; p <16; p++)
      for(int c = 0; c < 16; c++){
        int col =  image.get(c * 16 + 8, p * 16 + 8);
        palettes[p][c] = col;
        jpalettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
      }
  }
View Full Code Here

   */
  protected PImage[] getImages(String imgFile, int nbrImages){
    nbrImages = PApplet.constrain(nbrImages, 1, 3);

    PImage[] imgs = new PImage[3];
    PImage img = winApp.loadImage(imgFile);

    if(imgFile == null || img == null){
      missingFile(imgFile);
      imgs = getErrorImage();
    }
    else {
      int iw = img.width / nbrImages;
      for(int i = 0; i < nbrImages;  i++){
        imgs[i] = new PImage(iw, img.height, ARGB);
        imgs[i].copy(img,
            i * iw, 0, iw, img.height,
            0, 0, iw, img.height);
      }
      // Re use images if less than 3 were provided
View Full Code Here

   * Get the mask file. Report an error if the file cannot be found.
   * @param mfile
   * @return
   */
  protected PImage getMask(String mfile){
    PImage img = null;
    if(mfile != null){     
      img = winApp.loadImage(mfile);
      if(img == null)
        missingFile(mfile);
    }
View Full Code Here

    _rightEnd = winApp.loadImage(_skin + "/end_right.png");
    _thumb = winApp.loadImage(_skin +"/handle.png");
    _thumb_mouseover = winApp.loadImage(_skin +"/handle_mouseover.png");
    //load the centre image up temporarily as we will generate the final stretched
    //image to use shortly
    PImage cTemp = winApp.loadImage(_skin + "/centre.png");

    String files = "";

    //generate a list of files that aren't there
    if(_leftEnd == null)
      files += "end_left.png\n";
    if(_rightEnd == null)
      files += "end_right.png\n";
    if(_thumb == null)
      files += "handle.png\n";
    if(_thumb_mouseover == null)
      files += "handle_mouseover.png\n";
    if(cTemp == null)
      files += "centre.png\n";

    // See if we have problems with the skin files
    if(files != ""){
      PApplet.println("The following files could not be found for the skin " + _skin + ": \n" + files
          + "\nCheck that these files are correctly placed in the data directory under a folder with"
          + " the same name as the skin used.\n");
    }
    if(cTemp.width != 1){
      PApplet.println("The supplied centre image for this skin is not of width 1px.");
    }
    if(cTemp.height != _leftEnd.height || cTemp.height != _rightEnd.height){
      PApplet.println("The image components of the slider are not all the same height.");
    }

    this.height = cTemp.height;
    int cWidth = length - _leftEnd.width - _rightEnd.width;
    if(cWidth < 0){cWidth = 1;}

    _centre = new PImage(cWidth,cTemp.height);

    //now copy over the data from cTemp to main centre image
    //the standard PImage stretch method is no good in this case
    //appears better to do it manually.
    cTemp.loadPixels();
    _centre.loadPixels();

    for (int i = 0; i < _centre.height; i++) {
      for (int j = 0; j < _centre.width; j++) {
        _centre.pixels[i*_centre.width +j] = cTemp.pixels[i];
      }
    }
    _centre.updatePixels();
    cTemp.updatePixels();
   
    //the thumb only moves along the centre section
    thumbMin = _leftEnd.width;
    thumbMax = _leftEnd.width + _centre.width;
    this.setLimits(50.0f, 0.0f, 100.0f);
View Full Code Here

    size(700,840);
    String path = "../cathedrals";
    File[] files = this.getFilesFromFolder(path);
    PImage[] imageSet = new PImage[files.length];
    for (int i = 0; i < files.length; i++) {
      PImage img = this.loadImage(files[i].getAbsolutePath());
      imageSet[i] = img;
    }
    face=new PEigenface(this);
    face.initEigenfaces(imageSet);
    int nEigenfaces=20;
View Full Code Here

      if (weights[i]>=5000){
        weights[i]=5000;
        offsets[i]*=-1;
      }
    }
    PImage img=face.getImageByWeights(weights,25);
    image(img,0,0,width,height);
  }
View Full Code Here

  public void initEigenfaces(PImage[] imageSet) {
    this.imagesSet = imageSet;
    double[][] dataSet = new double[imageSet.length][];
    for (int i = 0; i < imageSet.length; i++) {
      PImage img = imageSet[i];
      this.imageHeight=img.height;
      this.imageWidth=img.width;
      dataSet[i] = getBrightnessArray(img);
      imageSet[i] = img;
    }
    initEigenfaces(dataSet);
   
    // calculate Images
    imagesEigen = new PImage[eigenFaces.length];
    for (int i = 0; i < eigenFaces.length; i++) {
      PImage eigen = getNormalizedImage(imageWidth, imageHeight,0,255, eigenFaces[i]);
      imagesEigen[i] = eigen;
    }
    reconstrucetedIamges=this.reconstructFaces(selectedNumOfEigenFaces);
  }
View Full Code Here

    double[] imageData=MatrixMath.multiply(weights, egnfacesSubMatrix);
    imageData = MatrixMath.add(imageData, dataAverage);
    return getImage(imageWidth, imageHeight, imageData);
  }
  public PImage getImageBW(int nX, int nY,float limit, double[] brightness) {
    PImage img = parent.createImage(nX, nY, PApplet.RGB);
    for (int i = 0; i < brightness.length; i++) {
      float b=Math.abs((int) brightness[i]);
      //if (b<0)b=0;
    if (b<limit)b=0;
      else{
        b=255;
      }
      img.pixels[i] = parent.color(b);
    }
    img.loadPixels();
    return img;
  }
View Full Code Here

TOP

Related Classes of processing.core.PImage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.