Package jMEF

Examples of jMEF.PVector


    // Conversion
    for (int row=0; row<height; row++)
      for (int col=0; col<width; col++){
        Color   c   = new Color(image.getRGB(col, row));
        PVector px  = new PVector(3);
        px.array[0] = c.getRed();
        px.array[1] = c.getGreen();
        px.array[2] = c.getBlue()
        points[ row * width + col ] = px;
      }
View Full Code Here


    // Conversion
    for (int row=0; row<height; row++)
      for (int col=0; col<width; col++){
        Color   c   = new Color(image.getRGB(col, row));
        PVector px  = new PVector(5);
        px.array[0] = c.getRed();
        px.array[1] = c.getGreen();
        px.array[2] = c.getBlue();
        px.array[3] = row;
        px.array[4] = col;     
View Full Code Here

    for (int row=0; row<imgIn.getHeight(); row++)
      for (int col=0; col<imgIn.getWidth(); col++){
             
        // Get the pixel
        Color c     = new Color(imgIn.getRGB(row, col));
        PVector px  = new PVector(3);
        px.array[0] = c.getRed();
        px.array[1] = c.getGreen();
        px.array[2] = c.getBlue();
       
        // Find and set the most probable class for the current point
View Full Code Here

    // Image initialization
    BufferedImage imgOut = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
   
    for (int i=0; i<f.size; i++){

      PVector mean = (PVector)((PVectorMatrix)f.param[i]).v.clone();
      Color c      = new Color((int)mean.array[0], (int)mean.array[1], (int)mean.array[2]);

      for (int row=0; row<height; row++)
        for (int col=0; col<width; col++){
         
          PVector x  = (PVector)mean.clone();
          x.array[3] = row;
          x.array[4] = col;

          double v = (x.Minus(((PVectorMatrix)f.param[i]).v)).InnerProduct(((PVectorMatrix)f.param[i]).M.Inverse().MultiplyVectorRight(x.Minus(((PVectorMatrix)f.param[i]).v)));
         
          if (v<t)
            imgOut.setRGB(col, row, c.getRGB());
        }
    }
View Full Code Here

    centroids[0]        = (PVector)points[rand.nextInt(points.length)].clone();
   
    // Initialize the other centroids
    for (int i=1; i<k; i++){
      boolean cond = false;
      PVector tmp;
      do{
        cond = false;
        tmp  = points[rand.nextInt(points.length)];
        for (int j=0; j<i; j++){
          if (PVector.equals(tmp, centroids[j])){
            cond = true;
            break;
          }
        }
      }while(cond);
      centroids[i] = (PVector)tmp.clone();
    }
   
    // Return
    return centroids;
  }
View Full Code Here

   * @param centroids  centroids of the clusters
   * @param clusters   clusters
   */
  private static void centroidStep(PVector[] points, int k, PVector[] centroids, Vector<PVector>[] clusters){
    for (int i=0; i<k; i++){
      centroids[i] = new PVector(points[0].dim);
      for (int j=0; j<clusters[i].size(); j++)
        centroids[i] = centroids[i].Plus((PVector)clusters[i].get(j));
      centroids[i] = centroids[i].Times(1.0d/clusters[i].size());
    }
  }
View Full Code Here

TOP

Related Classes of jMEF.PVector

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.