List of usage examples for java.awt Color getRed
public int getRed()
From source file:baocaoxla.xuly_compare.java
public int BHATTACHARYYA(BufferedImage image, BufferedImage imgcompare) { int[] his = new int[256]; int[] his1 = new int[256]; for (int i = 0; i < 256; i++) { his[i] = 0;/*from www .jav a2 s .c om*/ his1[i] = 0; } int width = image.getWidth(); int height = image.getHeight(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color c = new Color(image.getRGB(j, i)); his[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } int width1 = imgcompare.getWidth(); int height1 = imgcompare.getHeight(); for (int i = 0; i < height1; i++) { for (int j = 0; j < width1; j++) { Color c = new Color(imgcompare.getRGB(j, i)); his1[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } double sumhis = 0; double sumhis1 = 0; for (int i = 0; i < 256; i++) { sumhis = sumhis + his[i]; sumhis1 = sumhis1 + his1[i]; } double sum = 0; for (int i = 0; i < 256; i++) { sum = sum + Math.sqrt(his[i] * his1[i]); } int percent = (int) ((1 - Math.sqrt(1 - sum / Math.sqrt(sumhis * sumhis1))) * 100); System.out.print(Math.sqrt(1 - sum)); return percent; }
From source file:baocaoxla.xuly_compare.java
public int chi_square(BufferedImage image, BufferedImage imgcompare) { int[] his = new int[256]; int[] hisnomal = new int[256]; int[] his1 = new int[256]; for (int i = 0; i < 256; i++) { his[i] = 0;// w ww . j a v a2s . com hisnomal[i] = 0; his1[i] = 0; } int width = image.getWidth(); int height = image.getHeight(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color c = new Color(image.getRGB(j, i)); his[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; // hisnomal[255-(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } int width1 = imgcompare.getWidth(); int height1 = imgcompare.getHeight(); for (int i = 0; i < height1; i++) { for (int j = 0; j < width1; j++) { Color c = new Color(imgcompare.getRGB(j, i)); his1[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } double sum = 0; double sum1 = 0; for (int i = 0; i < 256; i++) { sum1 = sum1 + Math.pow(hisnomal[i] - his[i], 2) / (hisnomal[i] + his[i]); } for (int i = 0; i < 256; i++) { sum = sum + Math.pow(his1[i] - his[i], 2) / (his1[i] + his[i]); } int percent = (int) ((1 - sum / sum1) * 100); return percent; }
From source file:org.emonocot.portal.view.Functions.java
private static Map<String, String> getColorMap(Set<String> categories) { int numberOfCategories = categories.size(); float increment = 0.5f / (numberOfCategories / 5); Map<String, String> colorMap = new HashMap<String, String>(); int i = 0;//from w w w.jav a2 s .c o m for (String category : categories) { Color baseColor = baseColors[i % 5]; int offset = i / 5; if (offset > 0) { float hsbVals[] = Color.RGBtoHSB(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), null); Color highlight = Color.getHSBColor(hsbVals[0], hsbVals[1], offset * increment * (1f + hsbVals[2])); colorMap.put(category, String.format("#%06X", (0xFFFFFF & highlight.getRGB()))); } else { colorMap.put(category, String.format("#%06X", (0xFFFFFF & baseColor.getRGB()))); } i++; } return colorMap; }
From source file:org.neo4art.colour.service.ImageDefaultManager.java
/** * //from w w w . j ava 2 s . c om * @param color * @return */ public String getClosestColourName(Color color) { Colour colour = getClosestColour(color.getRed(), color.getGreen(), color.getBlue()); if (colour != null) { return colour.getName(); } return null; }
From source file:playground.johannes.socialnetworks.graph.spatial.io.KMLVertexColorStyle.java
public List<StyleType> getObjectStyle(G graph) { TDoubleObjectHashMap<String> values = getValues(graph); double[] keys = values.keys(); double min = StatUtils.min(keys); double max = StatUtils.max(keys); List<StyleType> styleTypes = new ArrayList<StyleType>(keys.length); styleIdMappings = new TDoubleObjectHashMap<String>(); for (double val : keys) { StyleType styleType = objectFactory.createStyleType(); styleType.setId(values.get(val)); IconStyleType iconStyle = objectFactory.createIconStyleType(); iconStyle.setIcon(vertexIconLink); iconStyle.setScale(0.5);/*from w ww . j a va2 s . c o m*/ // iconStyle.setScale(1.0); Color c = colorForValue(val, min, max); iconStyle.setColor( new byte[] { (byte) c.getAlpha(), (byte) c.getBlue(), (byte) c.getGreen(), (byte) c.getRed() }); styleType.setIconStyle(iconStyle); styleTypes.add(styleType); styleIdMappings.put(val, styleType.getId()); } return styleTypes; }
From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersPanel.java
public ClustersPanel(ClustersWindow window, List<CentroidCluster<PointPerson>> clusters) { super();// w w w. ja v a 2s .co m this.window = window; addLayer(new Layer(new AxisPainter(24 * 3600, 18 * 3600, 0, 6 * 3600, 3600, 3600, Color.DARK_GRAY))); PointsPainter pointsPainter = new PointsPainter(); float i = 0; for (org.apache.commons.math3.ml.clustering.Cluster<PointPerson> cluster : clusters) { //Color color = new Color((float)(Math.random()*0.5), (float)(Math.random()*0.5), (float)(Math.random()*0.5), 0.3f); float p = (i + 0.5f) / clusters.size(); Color color = JetColor.getJetColor(p); color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50); PointsPersonPainter ppPainter = new PointsPersonPainter(color); ppPainter.setWeightedPoints(cluster.getPoints()); addLayer(new Layer(ppPainter)); PointPerson center = cluster.getPoints().get(0).centroidOf(cluster.getPoints()); pointsPainter.addPoint(new CoordImpl(center.getElement(0), center.getElement(1))); i++; } addLayer(new Layer(pointsPainter)); this.setBackground(Color.WHITE); calculateBoundaries(); super.setPreferredSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); addKeyListener(this); setFocusable(true); }
From source file:gr.iti.mklab.reveal.forensics.util.Util.java
public static float[][][] getImageDifference(BufferedImage image1, BufferedImage image2) { Color tmpColor1, tmpColor2; int width = image1.getWidth(); int height = image1.getHeight(); float[][][] outputMap = new float[3][width][height]; for (int ii = 0; ii < width; ii++) { for (int jj = 0; jj < height; jj++) { tmpColor1 = new Color(image1.getRGB(ii, jj)); tmpColor2 = new Color(image2.getRGB(ii, jj)); outputMap[0][ii][jj] = (float) (tmpColor1.getRed() - tmpColor2.getRed()) * (tmpColor1.getRed() - tmpColor2.getRed()); outputMap[1][ii][jj] = (float) (tmpColor1.getGreen() - tmpColor2.getGreen()) * (tmpColor1.getGreen() - tmpColor2.getGreen()); outputMap[2][ii][jj] = (float) (tmpColor1.getBlue() - tmpColor2.getBlue()) * (tmpColor1.getBlue() - tmpColor2.getBlue()); }//from w w w . j a v a 2s . c om } return outputMap; }
From source file:baocaoxla.xuly_compare.java
public int Correlation(BufferedImage image, BufferedImage imgcompare) { //BufferedImage img=new BufferedImage(image.getWidth(),get, imageType) int[] his = new int[256]; int[] his1 = new int[256]; for (int i = 0; i < 256; i++) { his[i] = 0;/*from w w w .j a va 2 s .co m*/ his1[i] = 0; } int width = image.getWidth(); int height = image.getHeight(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color c = new Color(image.getRGB(j, i)); his[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } int width1 = imgcompare.getWidth(); int height1 = imgcompare.getHeight(); for (int i = 0; i < height1; i++) { for (int j = 0; j < width1; j++) { Color c = new Color(imgcompare.getRGB(j, i)); his1[(c.getRed() + c.getGreen() + c.getBlue()) / 3]++; } } double sumhis = 0; double sumhis1 = 0; for (int i = 0; i < 256; i++) { sumhis = sumhis + his[i]; sumhis1 = sumhis1 + his1[i]; } double tu = 0; double mau1 = 0; double mau2 = 0; for (int i = 0; i < 256; i++) { tu = tu + (his[i] - sumhis / 256) * (his1[i] - sumhis1 / 256); mau1 = mau1 + Math.pow((his[i] - sumhis / 256), 2); mau2 = mau2 + Math.pow((his1[i] - sumhis1 / 256), 2); } double mau = Math.sqrt(mau1 * mau2); int compare = (int) (((tu / mau) + 1) * 50); return compare; }
From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotPanel.java
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset, ParameterSet parameters) {/*from ww w. jav a 2 s .co m*/ super(null); boolean createLegend = false; if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20)) createLegend = true; chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset, PlotOrientation.VERTICAL, createLegend, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setForegroundAlpha(dataPointAlpha); NumberFormat numberFormat = NumberFormat.getNumberInstance(); // set the X axis (component 1) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(numberFormat); // set the Y axis (component 2) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(numberFormat); plot.setDataset(dataset); spotRenderer = new ProjectionPlotRenderer(plot, dataset); itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters); spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator); spotRenderer.setBaseItemLabelsVisible(true); spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters)); plot.setRenderer(spotRenderer); // Setup legend if (createLegend) { LegendItemCollection legendItemsCollection = new LegendItemCollection(); for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) { Object paramValue = dataset.getGroupParameterValue(groupNumber); if (paramValue == null) { // No parameter value available: search for raw data files // within this group, and use their names as group's name String fileNames = new String(); for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) { String rawDataFile = dataset.getRawDataFile(itemNumber); if (dataset.getGroupNumber(itemNumber) == groupNumber) fileNames = fileNames.concat(rawDataFile); } if (fileNames.length() == 0) fileNames = "Empty group"; paramValue = fileNames; } Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber); Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(), (int) Math.round(255 * dataPointAlpha)); legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null, spotRenderer.getDataPointsShape(), groupColor)); } plot.setFixedLegendItems(legendItemsCollection); } }
From source file:edu.ku.brc.ui.GradiantButton.java
/** * Sests the text Color/*from w w w . ja v a 2 s.co m*/ * @param textColor text color */ public void setTextColor(Color textColor) { this.textColor = textColor; textColorShadow = new Color(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), 70); }