Exemplo n.º 1
0
 private DefaultCategoryDataset createDataset() {
   DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset();
   for (String key : histogram.keySet()) {
     defaultCategoryDataset.addValue(histogram.get(key), "", key);
   }
   return defaultCategoryDataset;
 }
Exemplo n.º 2
0
 /**
  * A factory object which creates a histogram object for an image.
  *
  * @param fileName the file name of the image to compute a histogram.
  * @return A histogram object for the specified image.
  * @throws IOException if the specified image file does not exists or there is some problem
  *     reading it.
  */
 public static Histogram getHisrogram(String fileName) throws IOException {
   File f = new File(fileName);
   BufferedImage img = ImageIO.read(f);
   Histogram h = new Histogram(fileName);
   //        h.parseGrayHistogram(img);
   h.parseHistogramForColors(img);
   return h;
 }
Exemplo n.º 3
0
 public void actionPerformed(ActionEvent event) {
   Object source = new Object();
   source = event.getSource();
   String data, histo = "";
   if (source == btnRun) {
     Histogram gram = new Histogram(txtWord.getText());
     data = gram.getData();
     histo = gram.getHistogram();
     JOptionPane.showMessageDialog(null, data + "\n" + histo);
   }
 }
 private static void checkZeros(ExpDataManager expMan) {
   int neverabove = 0;
   int sometimes = 0;
   int always = 0;
   Histogram h = new Histogram(0.1);
   for (String gene : HGNC.getAllSymbols()) {
     if (!expMan.contains(gene)) continue;
     double r = expMan.getNonZeroRatio(gene);
     h.count(r);
     if (r == 0) neverabove++;
     else if (r == 1) always++;
     else sometimes++;
   }
   System.out.println("neverabove = " + neverabove);
   System.out.println("always = " + always);
   System.out.println("sometimes = " + sometimes);
   h.print();
 }
Exemplo n.º 5
0
  private synchronized void computeHistogram(Rectangle visibleRect, PlanarImage image) {
    int channels = image.getSampleModel().getNumBands();

    Histogram hist = new Histogram(256, 256, 512, channels);

    bins = hist.getBins();

    // Raster raster = image.getData(visibleRect);
    Rectangle bounds = visibleRect; // image.getBounds();
    int pixel[] = null;

    int maxPixels = 256;
    int incX = bounds.width >= 2 * maxPixels ? bounds.width / maxPixels : 1;
    int incY = bounds.height >= 2 * maxPixels ? bounds.height / maxPixels : 1;

    double log2 = Math.log(2);

    int minTileX = image.XToTileX(bounds.x);
    int maxTileX = image.XToTileX(bounds.x + bounds.width - 1);
    int minTileY = image.YToTileY(bounds.y);
    int maxTileY = image.YToTileY(bounds.y + bounds.height - 1);

    for (int tx = minTileX; tx <= maxTileX; tx++)
      for (int ty = minTileY; ty <= maxTileY; ty++) {
        Raster raster = image.getTile(tx, ty);

        int minX = Math.max(bounds.x, raster.getMinX());
        int maxX = Math.min(bounds.x + bounds.width, raster.getMinX() + raster.getWidth());
        int minY = Math.max(bounds.y, raster.getMinY());
        int maxY = Math.min(bounds.y + bounds.height, raster.getMinY() + raster.getHeight());

        for (int x = minX; x < maxX; x += incX)
          for (int y = minY; y < maxY; y += incY) {
            pixel = raster.getPixel(x, y, pixel);
            for (int c = 0; c < channels; c++) {
              int v = (int) (511 * logTable[pixel[c]] / (16 * log2));
              if (v > 255) bins[c][v - 256]++;
              else bins[c][0]++;
            }
          }
      }

    bins = hist.getBins();
  }
 private IntervalXYDataset getHistrogrammedDataAttributes(
     String[] attributes, long barsize, long timesize) {
   IntervalXYDataset dataset = null;
   if (no_intervals) {
     dataset = new XYSeriesCollection();
   } else {
     dataset = new YIntervalSeriesCollection();
   }
   for (int index = 0; index < attributes.length; index++) {
     Histogram histogram = new Histogram(barsize);
     String attribute = attributes[index];
     for (ProcessInstance pi : mylog.getInstances()) {
       Date begin;
       try {
         begin = pi.getAuditTrailEntryList().get(0).getTimestamp();
       } catch (Exception e) {
         Message.add(e.getMessage(), Message.ERROR);
         return null;
       } // starting time of process instance
       int j = 0;
       for (AuditTrailEntry ate : pi.getListOfATEs()) {
         if (ate.getAttributes().containsKey(attribute)) {
           Double val;
           val = Double.valueOf(ate.getAttributes().get(attribute));
           if (xbox.getSelectedIndex() == 2) {
             histogram.addValue(j, val);
           }
           if (xbox.getSelectedIndex() == 3) {
             histogram.addValue(timediff(begin, ate.getTimestamp()), val);
           }
           j++;
         }
       }
     }
     if (no_intervals) {
       ((XYSeriesCollection) dataset).addSeries(histogram.getXYSeries(attribute, timesize));
     } else {
       ((YIntervalSeriesCollection) dataset)
           .addSeries(histogram.getYIntervalSeries(attribute, timesize));
     }
   }
   return dataset;
 }