Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

In this page you can find the example usage for java.awt Color getBlue.

Prototype

public int getBlue() 

Source Link

Document

Returns the blue component in the range 0-255 in the default sRGB space.

Usage

From source file:wsattacker.sso.openid.attacker.evaluation.report.SvgOutput.java

private String colorToHex(Color color) {
    return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
}

From source file:util.ui.PictureAreaIcon.java

private boolean colorsInEqualRange(final Color c1, final Color c2) {
    return Math.abs(c1.getRed() - c2.getRed()) <= MAX_COLOR_DIFF
            && Math.abs(c1.getBlue() - c2.getBlue()) <= MAX_COLOR_DIFF
            && Math.abs(c1.getGreen() - c2.getGreen()) <= MAX_COLOR_DIFF;
}

From source file:org.jtrfp.trcl.file.LTEFile.java

/**
 * Reverse-compatible form of the emissive components in ESTuTv form where:<br>
 * R = E<br>/*from www  . java  2s  .c  o  m*/
 * G = S<br>
 * B = Tu<br>
 * A = Tv<br>
 * @return
 * @since Feb 5, 2015
 */
public Color[] toColors(Color[] referencePalette) {
    Color[] result = new Color[256];
    for (int i = 0; i < 256; i++) {
        final Color rColor = referencePalette[i];
        final Color loColor = referencePalette[gradientIndex(i, 0)];
        final Color hiColor = referencePalette[gradientIndex(i, 15)];
        final double loIntensity = new Vector3D(loColor.getRed(), loColor.getGreen(), loColor.getBlue())
                .getNorm();
        //Brightest
        final double hiIntensity = new Vector3D(hiColor.getRed(), hiColor.getGreen(), hiColor.getBlue())
                .getNorm();

        final float[] hsbVals = new float[3];
        Color.RGBtoHSB(rColor.getRed(), rColor.getGreen(), rColor.getBlue(), hsbVals);
        final double saturation = hsbVals[1];
        double dI = Math.pow(1 - (Math.abs(hiIntensity - loIntensity) / 442.), 1);
        //dI = nSaturation*128;
        if (dI > 255)
            dI = 255;
        else if (dI < 0)
            dI = 0;
        result[i] = new Color((int) (dI * saturation * 255.), 0, 0, 0);
    }
    return result;
}

From source file:org.neo4art.colour.service.ImageDefaultManager.java

/**
 * //from www.  j av  a2  s  .co m
 * @param red
 * @param green
 * @param blue
 * @return
 */
public Colour getClosestColour(Color color) {
    return getClosestColour(color.getRed(), color.getGreen(), color.getBlue());
}

From source file:baocaoxla.xuly_compare.java

public int intersection(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 w  w  w  .  ja  va 2  s .c o 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 summin = 0;
    double sumhis = 0;

    for (int i = 0; i < 256; i++) {
        summin = summin + Math.min(his[i], his1[i]);
        sumhis = sumhis + his[i];
    }
    int percentred = (int) ((summin / sumhis) * 100);
    return percentred;
}

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;/*w  w  w  .j  av 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;//from w w w .j ava2s  .  c  o m
        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:com.gargoylesoftware.htmlunit.javascript.host.canvas.rendering.AwtRenderingBackend.java

/**
 * {@inheritDoc}//from   w  w  w .j  av a 2  s.c om
 */
public byte[] getBytes(final int width, final int height, final int sx, final int sy) {
    final byte[] array = new byte[width * height * 4];
    int index = 0;
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            final Color c = new Color(image_.getRGB(sx + x, sy + y), true);
            array[index++] = (byte) c.getRed();
            array[index++] = (byte) c.getGreen();
            array[index++] = (byte) c.getBlue();
            array[index++] = (byte) c.getAlpha();
        }
    }
    return array;
}

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;// ww  w .j av a  2s  .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 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:org.neo4art.colour.service.ImageDefaultManager.java

/**
 * /*from  w ww. j  a  v  a  2 s .  co  m*/
 * @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;
}