List of usage examples for org.apache.commons.math.stat.descriptive DescriptiveStatistics addValue
public void addValue(double v)
From source file:edu.usc.goffish.gopher.sample.N_Hop_Stat_Collector.java
@Override public void compute(List<SubGraphMessage> subGraphMessages) { /**//from w ww. j ava2 s.c o m * We do this in following steps. * Calculate stats for each subgraph. * Calculate aggregate stats for partition. * In this case a single sub-graph will do the aggregation * Aggregate partition level stats and combine at the smallest partition. */ if (superStep == 0) { SubGraphMessage msg = subGraphMessages.get(0); String data = new String(msg.getData()); String[] dataSplit = data.split("#"); N = Integer.parseInt(dataSplit[0]); String[] vps = dataSplit[1].split(","); for (String vp : vps) { vantagePoints.add(vp.trim()); } try { Iterable<? extends ISubgraphInstance> subgraphInstances = subgraph.getInstances(Long.MIN_VALUE, Long.MAX_VALUE, PropertySet.EmptyPropertySet, subgraph.getEdgeProperties(), false); // sliceManager.readInstances(subgraph, // Long.MIN_VALUE, Long.MAX_VALUE, // PropertySet.EmptyPropertySet, subgraph.getEdgeProperties()); for (ISubgraphInstance instance : subgraphInstances) { Map<String, DescriptiveStatistics> statsMap = new HashMap<String, DescriptiveStatistics>(); for (TemplateEdge edge : subgraph.edges()) { ISubgraphObjectProperties edgeProps = instance.getPropertiesForEdge(edge.getId()); Integer isExist = (Integer) edgeProps.getValue(IS_EXIST_PROP); if (isExist == 1) { String[] vantageIps = ((String) edgeProps.getValue(VANTAGE_IP_PROP)).split(","); String[] latencies = ((String) edgeProps.getValue(LATENCY_PROP)).split(","); String[] hops = ((String) edgeProps.getValue(HOP_PROP)).split(","); Integer[] vantangeIdx = vantageIpIndex(vantageIps); if (vantangeIdx == null) { continue; } for (int i : vantangeIdx) { String vantage = vantageIps[i]; String latency = latencies[i]; String hop = hops[i]; double latency_num = Double.parseDouble(latency); int hop_num = Integer.parseInt(hop); if (latency_num >= 0 && hop_num == N) { if (statsMap.containsKey(vantage)) { statsMap.get(vantage).addValue(latency_num); } else { DescriptiveStatistics statistics = new DescriptiveStatistics(); statistics.addValue(latency_num); statsMap.put(vantage, statistics); } } ; } } } int c = 0; StringBuffer msgBuffer = new StringBuffer(); for (String v : statsMap.keySet()) { c++; DescriptiveStatistics statistics = statsMap.get(v); String m = createMessageString(v, instance.getTimestampStart(), instance.getTimestampEnd(), statistics.getStandardDeviation(), statistics.getMean(), statistics.getN()); if (c == statsMap.keySet().size()) { msgBuffer.append(m); } else { msgBuffer.append(m).append("|"); } } SubGraphMessage subMsg = new SubGraphMessage(msgBuffer.toString().getBytes()); sentMessage(partition.getId(), subMsg); } } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } } else if (superStep == 1) { //Ok here every sub-graph will receive message from its own partition. //Each message is belongs to a given some time span. Map<String, List<String[]>> vantageGroup = new HashMap<String, List<String[]>>(); for (SubGraphMessage subGraphMessage : subGraphMessages) { String msgData = new String(subGraphMessage.getData()); String[] dataParts = msgData.split("|"); for (String data : dataParts) { String[] vantageParts = data.split(","); //Group by vantage point and startTime if (vantageGroup.containsKey(vantageParts[0] + "|" + vantageParts[1])) { vantageGroup.get(vantageParts[0] + "|" + vantageParts[1]).add(vantageParts); } else { ArrayList<String[]> arrayList = new ArrayList<String[]>(); arrayList.add(vantageParts); vantageGroup.put(vantageParts[0] + "|" + vantageParts[1], arrayList); } } } for (String key : vantageGroup.keySet()) { if (!acquireLock(key)) { continue; } List<String[]> data = vantageGroup.get(key); double totalN = 0; double totalAvgVal = 0; double totalVar = 0; for (String[] d : data) { //average double mean = Double.parseDouble(d[4]); long sN = Long.parseLong(d[5]); totalN += sN; totalAvgVal += mean * sN; double sd = Double.parseDouble(d[3]); totalVar += ((double) sd * sd) / ((double) sN); } double avg = totalAvgVal / totalN; double newSD = Math.sqrt(totalVar); //create message //sent to all the partitions except me. String msg = key + "," + newSD + "," + avg + "," + totalN; for (int pid : partitions) { sentMessage(pid, new SubGraphMessage(msg.getBytes())); } } } else if (superStep >= 2) { if (partition.getId() == Collections.min(partitions)) { Map<String, List<String[]>> group = new HashMap<String, List<String[]>>(); for (SubGraphMessage msg : subGraphMessages) { String data = new String(msg.getData()); String[] dataParts = data.split(","); if (group.containsKey(dataParts[0])) { group.get(dataParts[0]).add(dataParts); } else { List<String[]> list = new ArrayList<String[]>(); list.add(dataParts); group.put(dataParts[0], list); } } if (!acquireLock("" + partition.getId())) { voteToHalt(); return; } PrintWriter writer; try { writer = new PrintWriter(new FileWriter("TimeSeriesStats.csv")); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } for (String key : group.keySet()) { List<String[]> data = group.get(key); double totalN = 0; double totalAvgVal = 0; double totalVar = 0; for (String[] d : data) { //average //key + "," + newSD + "," + avg + "," + totalN; double mean = Double.parseDouble(d[2]); long sN = Long.parseLong(d[3]); totalN += sN; totalAvgVal += mean * sN; double sd = Double.parseDouble(d[1]); totalVar += ((double) sd * sd) / ((double) sN); } double avg = totalAvgVal / totalN; double newSD = Math.sqrt(totalVar); String vantage = key.split("|")[0]; String timeStamp = key.split("|")[1]; log(writer, vantage, timeStamp, avg, newSD); } writer.flush(); voteToHalt(); } } }
From source file:com.joliciel.jochre.graphics.JochreImageImpl.java
public double getAverageRowHeight() { if (averageRowHeight == 0) { DescriptiveStatistics rowHeightStats = new DescriptiveStatistics(); for (Paragraph paragraph : this.getParagraphs()) { for (RowOfShapes row : paragraph.getRows()) { int height = row.getXHeight(); rowHeightStats.addValue(height); }/*from w ww. j a v a 2s . c om*/ } averageRowHeight = rowHeightStats.getPercentile(50); LOG.debug("averageRowHeight: " + averageRowHeight); } return averageRowHeight; }
From source file:guineu.modules.dataanalysis.anova.AnovaTestTask.java
private double anova(List<String> groups, PeakListRow row) { try {//from w ww . j av a2 s. c o m DescriptiveStatistics stats1 = new DescriptiveStatistics(); List<double[]> classes = new ArrayList<double[]>(); for (String group : groups) { List<Double> values = new ArrayList<Double>(); for (String name : dataset.getAllColumnNames()) { if (dataset.getParametersValue(name, parameter) != null && dataset.getParametersValue(name, parameter).equals(group)) { try { values.add((Double) row.getPeak(name)); stats1.addValue((Double) row.getPeak(name)); } catch (Exception e) { System.out.println(row.getPeak(name)); } } } double[] valuesArray = new double[values.size()]; for (int i = 0; i < values.size(); i++) { valuesArray[i] = values.get(i).doubleValue(); } classes.add(valuesArray); } if (stats1.getVariance() == 0) return -1; return TestUtils.oneWayAnovaPValue(classes); } catch (IllegalArgumentException ex) { ex.printStackTrace(); return -1; } catch (MathException ex) { ex.printStackTrace(); return -1; } }
From source file:de.mpicbg.knime.hcs.base.nodes.preproc.ParameterMutualInformation.java
@Override protected BufferedDataTable[] execute(BufferedDataTable[] inData, ExecutionContext exec) throws Exception { BufferedDataTable input = inData[0]; // Get the parameter and make sure there all double value columns List<Attribute> parameters = getParameterList(input); // Initialize int Np = parameters.size(); int iterations = Np * 2; double[][] mutmatrix = new double[Np][Np]; double[][] sigmatrix = new double[Np][Np]; ;/*from w w w . j a v a 2 s . c om*/ double[][] biamatrix = new double[Np][Np]; ; MutualInformation mutualinfo = new MutualInformation(); mutualinfo.set_base(logbase.getDoubleValue()); mutualinfo.set_method(method.getStringValue()); mutualinfo.set_axeslinking(linkaxes.getBooleanValue()); if (binning.getIntValue() > 0) mutualinfo.set_binning(binning.getIntValue()); // Load data. Double[][] table = new Double[Np][input.getRowCount()]; int j = 0; for (DataRow row : input) { int i = 0; for (Attribute param : parameters) { table[i][j] = param.getDoubleAttribute(row); i++; } j++; exec.checkCanceled(); } BufTableUtils.updateProgress(exec, Np, iterations); // Calculate mutual information for (int a = 0; a < Np; a++) { mutualinfo.set_xvector(table[a]); for (int b = a; b < Np; b++) { mutualinfo.set_yvector(table[b]); // Calculate the mutual info. Double[] res = mutualinfo.calculate(); // Put it into the output matrix mutmatrix[a][b] = res[0]; mutmatrix[b][a] = res[0]; sigmatrix[a][b] = res[1]; sigmatrix[b][a] = res[1]; biamatrix[a][b] = res[2]; biamatrix[b][a] = res[2]; } BufTableUtils.updateProgress(exec, Np + a, iterations); exec.checkCanceled(); } // Create Tables BufferedDataContainer matrixContainer = exec.createDataContainer(new DataTableSpec(getMatrixSpec())); BufferedDataContainer listContainer = exec.createDataContainer(new DataTableSpec(getListSpec())); double thresh = threshold.getDoubleValue(); int numListCol = listContainer.getTableSpec().getNumColumns(); for (int a = 0; a < Np; a++) { // Initialize DataCell[] matrixCells = new DataCell[Np]; DataCell[] listCells = new DataCell[numListCol]; String similars = ""; DescriptiveStatistics mutstats = new DescriptiveStatistics(); DescriptiveStatistics sigstats = new DescriptiveStatistics(); ; DescriptiveStatistics biastats = new DescriptiveStatistics(); ; // Create matrix rows and collect values for statistics. for (int b = 0; b < Np; b++) { matrixCells[b] = new DoubleCell(mutmatrix[a][b]); if (a != b) { mutstats.addValue(mutmatrix[a][b]); sigstats.addValue(sigmatrix[a][b]); biastats.addValue(biamatrix[a][b]); if (mutmatrix[a][b] > thresh) { similars += parameters.get(b).getName() + ","; } } } // Create matrix row DataRow matrixRow = new DefaultRow(parameters.get(a).getName(), matrixCells); matrixContainer.addRowToTable(matrixRow); // Create list row listCells[0] = new StringCell(parameters.get(a).getName()); listCells[1] = new DoubleCell(mutstats.getMin()); listCells[2] = new DoubleCell(mutstats.getMean()); listCells[3] = new DoubleCell(mutstats.getMax()); listCells[4] = new DoubleCell(sigstats.getGeometricMean()); listCells[5] = new DoubleCell(biastats.getMean()); listCells[6] = new StringCell(similars); DataRow listRow = new DefaultRow("row" + a, listCells); listContainer.addRowToTable(listRow); exec.checkCanceled(); } matrixContainer.close(); listContainer.close(); return new BufferedDataTable[] { listContainer.getTable(), matrixContainer.getTable() }; }
From source file:guineu.modules.dataanalysis.kstest.KSTestTask.java
public void run() { try {/*from w ww. ja v a 2 s.com*/ final Rengine rEngine; try { rEngine = RUtilities.getREngine(); } catch (Throwable t) { throw new IllegalStateException( "Kolmogorov-Smirnov test requires R but it couldn't be loaded (" + t.getMessage() + ')'); } synchronized (RUtilities.R_SEMAPHORE) { DescriptiveStatistics stats = new DescriptiveStatistics(); // assing the values to the matrix for (int row = 0; row < dataset.getNumberRows(); row++) { rEngine.eval("x <- vector(mode=\"numeric\",length=" + dataset.getNumberCols() + ")"); stats.clear(); PeakListRow peakListRow = dataset.getRow(row); for (int c = 0; c < dataset.getNumberCols(); c++) { int r = c + 1; double value = (Double) peakListRow.getPeak(dataset.getAllColumnNames().get(c)); rEngine.eval("x[" + r + "] <- " + value); stats.addValue(value); } rEngine.eval("y <- rnorm(" + dataset.getNumberCols() + ", mean= " + stats.getMean() + ", sd = " + stats.getStandardDeviation() + ")"); rEngine.eval("result <- ks.test(x,y)"); long e = rEngine.rniParse("result$p.value", 1); long r = rEngine.rniEval(e, 0); REXP x = new REXP(rEngine, r); double pValue = x.asDouble(); dataset.getRow(row).setVar("setPValue", pValue); if (peakListRow.getID() == 68) { rEngine.eval("write.csv(x, \"x.csv\""); } } } rEngine.end(); setStatus(TaskStatus.FINISHED); } catch (Exception ex) { Logger.getLogger(KSTestTask.class.getName()).log(Level.SEVERE, null, ex); setStatus(TaskStatus.ERROR); } }
From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.heatmaps.HeatMapTask.java
private void scale(double[][] peakList) { DescriptiveStatistics stdDevStats = new DescriptiveStatistics(); for (int columns = 0; columns < peakList.length; columns++) { stdDevStats.clear();/*w w w. ja v a 2 s .co m*/ for (int row = 0; row < peakList[columns].length; row++) { if (!Double.isInfinite(peakList[columns][row]) && !Double.isNaN(peakList[columns][row])) { stdDevStats.addValue(peakList[columns][row]); } } double stdDev = stdDevStats.getStandardDeviation(); for (int row = 0; row < peakList[columns].length; row++) { if (stdDev != 0) { peakList[columns][row] = peakList[columns][row] / stdDev; } } } }
From source file:guineu.modules.dataanalysis.foldChanges.FoldTestTask.java
public double Foldtest(int mol) throws IllegalArgumentException, MathException { DescriptiveStatistics stats1 = new DescriptiveStatistics(); DescriptiveStatistics stats2 = new DescriptiveStatistics(); String parameter1 = ""; try {/*from ww w . ja v a 2s. c o m*/ // Determine groups for selected raw data files List<String> availableParameterValues = dataset.getParameterAvailableValues(parameter); int numberOfGroups = availableParameterValues.size(); if (numberOfGroups > 1) { parameter1 = availableParameterValues.get(0); String parameter2 = availableParameterValues.get(1); for (String sampleName : dataset.getAllColumnNames()) { if (dataset.getParametersValue(sampleName, parameter) != null && dataset.getParametersValue(sampleName, parameter).equals(parameter1)) { stats1.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName)); } else if (dataset.getParametersValue(sampleName, parameter) != null && dataset.getParametersValue(sampleName, parameter).equals(parameter2)) { stats2.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName)); } } } else { return -1; } } catch (Exception e) { e.printStackTrace(); } if (stats1.getN() > 0 && stats2.getN() > 0) { /*double[] sortValues1 = stats1.getSortedValues(); double[] sortValues2 = stats2.getSortedValues(); return sortValues1[((int) stats1.getN() / 2)] / sortValues2[((int) stats2.getN() / 2)];*/ return stats1.getMean() / stats2.getMean(); } else { return 0; } }
From source file:guineu.modules.dataanalysis.Ttest.TTestTask.java
public double[] Ttest(int mol) throws IllegalArgumentException, MathException { DescriptiveStatistics stats1 = new DescriptiveStatistics(); DescriptiveStatistics stats2 = new DescriptiveStatistics(); double[] values = new double[3]; String parameter1 = ""; try {// ww w. java 2 s . c o m // Determine groups for selected raw data files List<String> availableParameterValues = dataset.getParameterAvailableValues(parameter); int numberOfGroups = availableParameterValues.size(); if (numberOfGroups > 1) { parameter1 = availableParameterValues.get(0); String parameter2 = availableParameterValues.get(1); for (String sampleName : dataset.getAllColumnNames()) { if (dataset.getParametersValue(sampleName, parameter) != null && dataset.getParametersValue(sampleName, parameter).equals(parameter1)) { try { stats1.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName)); } catch (Exception e) { } } else if (dataset.getParametersValue(sampleName, parameter) != null && dataset.getParametersValue(sampleName, parameter).equals(parameter2)) { try { stats2.addValue((Double) this.dataset.getRow(mol).getPeak(sampleName)); } catch (Exception e) { } } } } else { return null; } } catch (Exception e) { } TTestImpl ttest = new TTestImpl(); values[0] = ttest.tTest((StatisticalSummary) stats1, (StatisticalSummary) stats2); values[1] = stats1.getMean(); values[2] = stats2.getMean(); return values; }
From source file:com.joliciel.jochre.graphics.SourceImageImpl.java
public SourceImageImpl(GraphicsServiceInternal graphicsService, String name, BufferedImage image) { super(image); this.name = name; this.setOriginalImage(image); this.setGraphicsService(graphicsService); this.setWidth(this.getPixelGrabber().getWidth()); this.setHeight(this.getPixelGrabber().getHeight()); // to normalise the image, we need to figure out where black and white are // we want to leave out anomalies (ink blots!) int[] pixelSpread = new int[256]; // To save on memory for (int y = 0; y < this.getHeight(); y++) for (int x = 0; x < this.getWidth(); x++) { int pixel = this.getPixelGrabber().getPixelBrightness(x, y); pixelSpread[pixel]++;/* w w w . j a v a 2s . c o m*/ } if (LOG.isTraceEnabled()) { for (int i = 0; i < 256; i++) LOG.trace("Brightness " + i + ": " + pixelSpread[i]); } DescriptiveStatistics countStats = new DescriptiveStatistics(); for (int i = 0; i < 256; i++) { countStats.addValue(pixelSpread[i]); } int startWhite = -1; int endWhite = -1; for (int i = 255; i >= 0; i--) { if (startWhite < 0 && pixelSpread[i] > countStats.getMean()) startWhite = i; if (startWhite >= 0 && endWhite < 0 && pixelSpread[i] < countStats.getMean()) { endWhite = i; break; } } LOG.debug("Start white: " + startWhite); LOG.debug("End white: " + endWhite); DescriptiveStatistics blackCountStats = new DescriptiveStatistics(); DescriptiveStatistics blackSpread = new DescriptiveStatistics(); for (int i = 0; i <= endWhite; i++) { blackCountStats.addValue(pixelSpread[i]); for (int j = 0; j < pixelSpread[i]; j++) { blackSpread.addValue(i); } } LOG.debug("mean counts: " + countStats.getMean()); LOG.debug("mean black counts: " + blackCountStats.getMean()); LOG.debug("std dev black counts: " + blackCountStats.getStandardDeviation()); int startBlack = -1; for (int i = 0; i < 256; i++) { if (pixelSpread[i] > blackCountStats.getMean()) { startBlack = i; break; } } LOG.debug("Start black: " + startBlack); this.setBlackLimit(startBlack); this.setWhiteLimit(startWhite); this.greyscaleMultiplier = (255.0 / (double) (whiteLimit - blackLimit)); // use mean + 2 sigma to find the black threshold // we make the threshold high (darker) to put more pixels in the letter when analysing double blackthresholdCount = blackCountStats.getMean() + (2.0 * blackCountStats.getStandardDeviation()); LOG.debug("blackthresholdCount: " + blackthresholdCount); int blackThresholdValue = endWhite; for (int i = endWhite; i >= startBlack; i--) { if (pixelSpread[i] < blackthresholdCount) { blackThresholdValue = i; break; } } LOG.debug("Black threshold value (old): " + blackThresholdValue); blackThreshold = (int) Math.round((blackThresholdValue - blackLimit) * greyscaleMultiplier); LOG.debug("Black threshold (old): " + blackThreshold); blackThresholdValue = (int) Math.round(blackSpread.getPercentile(60.0)); LOG.debug("Black threshold value (new): " + blackThresholdValue); LOG.debug("Black spread 25 percentile: " + (int) Math.round(blackSpread.getPercentile(25.0))); LOG.debug("Black spread 50 percentile: " + (int) Math.round(blackSpread.getPercentile(50.0))); LOG.debug("Black spread 75 percentile: " + (int) Math.round(blackSpread.getPercentile(75.0))); blackThreshold = (int) Math.round((blackThresholdValue - blackLimit) * greyscaleMultiplier); LOG.debug("Black threshold (new): " + blackThreshold); // use mean + 1 sigma to find the separation threshold // we keep threshold low (1 sigma) to encourage letter breaks double separationthresholdCount = blackCountStats.getMean() + (1.0 * blackCountStats.getStandardDeviation()); LOG.debug("Separation threshold value: " + separationthresholdCount); int separationThresholdValue = endWhite; for (int i = endWhite; i >= startBlack; i--) { if (pixelSpread[i] < separationthresholdCount) { separationThresholdValue = i; break; } } LOG.debug("Separation threshold value (old): " + separationThresholdValue); separationThresholdValue = (int) Math.round(blackSpread.getPercentile(75.0)); LOG.debug("Separation threshold value (new): " + separationThresholdValue); LOG.debug("Black spread 25 percentile: " + (int) Math.round(blackSpread.getPercentile(25.0))); LOG.debug("Black spread 50 percentile: " + (int) Math.round(blackSpread.getPercentile(50.0))); LOG.debug("Black spread 75 percentile: " + (int) Math.round(blackSpread.getPercentile(75.0))); separationThreshold = (int) Math.round((separationThresholdValue - blackLimit) * greyscaleMultiplier); LOG.debug("Separation threshold: " + separationThreshold); if (drawPixelSpread) this.drawChart(pixelSpread, countStats, blackCountStats, blackSpread, startWhite, endWhite, startBlack, blackThresholdValue); }
From source file:com.joliciel.jochre.graphics.SourceImageImpl.java
@Override public List<Rectangle> getWhiteAreas(List<Shape> shapes) { LOG.debug("#### getWhiteAreas ####"); // Delimit area to be examined based on shapes int top = Integer.MAX_VALUE, bottom = 0, left = Integer.MAX_VALUE, right = 0; for (Shape shape : shapes) { if (shape.getTop() < top) top = shape.getTop();//from w w w.jav a 2 s . c o m if (shape.getBottom() > bottom) bottom = shape.getBottom(); if (shape.getLeft() < left) left = shape.getLeft(); if (shape.getRight() > right) right = shape.getRight(); } // get average shape width & height DescriptiveStatistics shapeWidthStats = new DescriptiveStatistics(); DescriptiveStatistics shapeHeightStats = new DescriptiveStatistics(); for (Shape shape : shapes) { shapeWidthStats.addValue(shape.getWidth()); shapeHeightStats.addValue(shape.getHeight()); } double averageShapeWidth = shapeWidthStats.getPercentile(75); double averageShapeHeight = shapeHeightStats.getPercentile(75); LOG.debug("averageShapeWidth: " + averageShapeWidth); LOG.debug("averageShapeHeight: " + averageShapeHeight); List<Rectangle> whiteAreas = new ArrayList<Rectangle>(); // Horizontal white areas double minHorizontalWhiteAreaWidth = 40.0 * averageShapeWidth; double minHorizontalWhiteAreaHeight = 2.5 * averageShapeHeight; LOG.debug("minHorizontalWhiteAreaWidth: " + minHorizontalWhiteAreaWidth); LOG.debug("minHorizontalWhiteAreaHeight: " + minHorizontalWhiteAreaHeight); WhiteAreaFinder whiteAreaFinder = new WhiteAreaFinder(); List<Rectangle> blackAreas = new ArrayList<Rectangle>(); blackAreas.addAll(shapes); List<Rectangle> horizontalWhiteAreas = whiteAreaFinder.getWhiteAreas(blackAreas, left, top, right, bottom, minHorizontalWhiteAreaWidth, minHorizontalWhiteAreaHeight); // we add the horizontal white areas to the "black areas", since we don't want vertical // white areas detected at page top & page bottom, splitting a valid row blackAreas.addAll(horizontalWhiteAreas); whiteAreas.addAll(horizontalWhiteAreas); // Long vertical white areas double minVerticalWhiteAreaWidth = 2.5 * averageShapeWidth; double minVerticalWhiteAreaHeight = 10.0 * averageShapeHeight; LOG.debug("minVerticalWhiteAreaWidth: " + minVerticalWhiteAreaWidth); LOG.debug("minVerticalWhiteAreaHeight: " + minVerticalWhiteAreaHeight); List<Rectangle> verticalWhiteAreas = whiteAreaFinder.getWhiteAreas(blackAreas, left, top, right, bottom, minVerticalWhiteAreaWidth, minVerticalWhiteAreaHeight); whiteAreas.addAll(verticalWhiteAreas); // Square white areas double minSquareWhiteAreaWidth = 4.0 * averageShapeWidth; double minSquareWhiteAreaHeight = 4.0 * averageShapeHeight; LOG.debug("minSquareWhiteAreaWidth: " + minSquareWhiteAreaWidth); LOG.debug("minSquareWhiteAreaHeight: " + minSquareWhiteAreaHeight); List<Rectangle> squareWhiteAreas = whiteAreaFinder.getWhiteAreas(blackAreas, left, top, right, bottom, minSquareWhiteAreaWidth, minSquareWhiteAreaHeight); whiteAreas.addAll(squareWhiteAreas); blackAreas.addAll(squareWhiteAreas); blackAreas.addAll(this.getWhiteAreasAroundLargeShapes(shapes)); // Long narrow vertical white areas minVerticalWhiteAreaWidth = 1.0 * averageShapeWidth; minVerticalWhiteAreaHeight = 20.0 * averageShapeHeight; LOG.debug("minVerticalWhiteAreaWidth: " + minVerticalWhiteAreaWidth); LOG.debug("minVerticalWhiteAreaHeight: " + minVerticalWhiteAreaHeight); List<Rectangle> verticalWhiteAreas2 = whiteAreaFinder.getWhiteAreas(blackAreas, left, top, right, bottom, minVerticalWhiteAreaWidth, minVerticalWhiteAreaHeight); whiteAreas.addAll(verticalWhiteAreas2); return whiteAreas; }