Package Jama

Examples of Jama.Matrix


                                           ColorScience.CAMethod caMethod) {
        return whiteBalance(image, source, REF_T, tint, lightness, 1, null, caMethod);
    }

    static public float[][] whiteBalanceMatrix(float source, float REF_T, float mult, float cameraRGB[][], ColorScience.CAMethod caMethod) {
        Matrix B = new Matrix(ColorScience.chromaticAdaptation(REF_T, source, caMethod));
        Matrix combo = XYZtoRGB.times(B.times(RGBtoZYX));

        Matrix m = combo.times(new Matrix(new double[][]{{1},{1},{1}}));

        double max = m.get(1, 0); // Math.max(m.get(1, 0), Math.max(m.get(1, 0), m.get(2, 0)));
        if (max != 1)
            combo = combo.times(new Matrix(new double[][]{{1/max, 0, 0},{0, 1/max, 0},{0, 0, 1/max}}));

        if (cameraRGB != null)
            combo = combo.times(new Matrix(cameraRGB));

        if (mult != 1)
            combo = combo.times(mult);

        return combo.getArrayFloat();
View Full Code Here


    public static float[][] RGBtoZYX() {
        double mdata[][] = new double[3][3];
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                mdata[i][j] = rgbXYZ[i][j];
        Matrix XYZRGB = new Matrix(mdata);

        float[][] S = new Matrix(new double[][] {{wtptXYZ[0], wtptXYZ[1], wtptXYZ[2]}}).times(XYZRGB.inverse()).getArrayFloat();

        return new float[][] {
            {S[0][0] * rgbXYZ[0][0], S[0][0] * rgbXYZ[0][1], S[0][0] * rgbXYZ[0][2]},
            {S[0][1] * rgbXYZ[1][0], S[0][1] * rgbXYZ[1][1], S[0][1] * rgbXYZ[1][2]},
            {S[0][2] * rgbXYZ[2][0], S[0][2] * rgbXYZ[2][1], S[0][2] * rgbXYZ[2][2]}
 
View Full Code Here

        float G[] = {Cxy[1][0], Cxy[1][1], 1 - Cxy[1][0] - Cxy[1][1]};
        float B[] = {Cxy[2][0], Cxy[2][1], 1 - Cxy[2][0] - Cxy[2][1]};
        float W[] = {DT[0], DT[1], 1 - DT[0] - DT[1]};

        // Compute luminance weights for the primaries using the white point
        Matrix RGB = vec(R, G, B);
        Matrix WGB = vec(W, G, B);
        Matrix RWB = vec(R, W, B);
        Matrix RGW = vec(R, G, W);

        float rgbDet = (float) RGB.det();

        return new float[] {(R[1] * (float) WGB.det()) / (W[1] * rgbDet),
                            (G[1] * (float) RWB.det()) / (W[1] * rgbDet),
                            (B[1] * (float) RGW.det()) / (W[1] * rgbDet)};
    }
View Full Code Here

            };
        }
    }

    static Matrix vec(float[] A, float[] B, float[] C) {
        Matrix ABC = new Matrix(3, 3);
        for (int i = 0; i < 3; i++)
            ABC.set(i, 0, A[i]);
        for (int i = 0; i < 3; i++)
            ABC.set(i, 1, B[i]);
        for (int i = 0; i < 3; i++)
            ABC.set(i, 2, C[i]);
        return ABC;
    }
View Full Code Here

            default:
                method = XYZScaling;
                break;
        }

        Matrix B = new Matrix(method);

        // source illuminant tristimulus in cone response domain
        float[] sXYZ = xy2XYZ(D(source));
        sXYZ = new Matrix(new float[][] {{sXYZ[0], sXYZ[1], sXYZ[2]}}).times(B).getArrayFloat()[0];

        // target illuminant tristimulus in cone response domain
        float[] tXYZ = xy2XYZ(D(target));
        tXYZ = new Matrix(new float[][] {{tXYZ[0], tXYZ[1], tXYZ[2]}}).times(B).getArrayFloat()[0];

        // scaling matrix for the colors
        float[][] diag = new float[][]{
            {sXYZ[0] / tXYZ[0], 0, 0},
            {0, sXYZ[1] / tXYZ[1], 0},
            {0, 0, sXYZ[2] / tXYZ[2]}
        };

        // total tansform
        return B.times(new Matrix(diag)).times(B.inverse()).getArrayFloat();
    }
View Full Code Here

        float sat = Float.MAX_VALUE;
        float minT = 0;
        double wbr = 0, wbg = 0, wbb = 0;
        float tint = 0;

        Matrix color = new Matrix(new double[][]{{rgb[0]}, {rgb[1]}, {rgb[2]}});

        for (int t = 1000; t < 40000; t+= (0.001 * t)) {
            Matrix B = new Matrix(chromaticAdaptation(t, refT, caMethod));
            Matrix combo = XYZtoRGB.times(B.times(RGBtoZYX));

            Matrix adapdedColor = combo.times(color);

            double r = clip(adapdedColor.get(0, 0));
            double g = clip(adapdedColor.get(1, 0));
            double b = clip(adapdedColor.get(2, 0));

            float tSat = (float) saturation(r, g, b);

            if (tSat < sat) {
                sat = tSat;
View Full Code Here

        float minT = 0;

        float[] xyzRef = JAIContext.linearColorSpace.toCIEXYZ(rgb);
        float[] labRef = JAIContext.labColorSpace.fromCIEXYZ(xyzRef);       

        Matrix gray = new Matrix(new double[][]{{0.18}, {0.18}, {0.18}});

        for (int t = 1000; t < 40000; t+= (0.001 * t)) {
            Matrix B = new Matrix(chromaticAdaptation(t, refT, caMethod));
            Matrix combo = XYZtoRGB.times(B.times(RGBtoZYX));

            gray = combo.times(gray);

            double r = clip(gray.get(0, 0));
            double g = clip(gray.get(1, 0));
            double b = clip(gray.get(2, 0));

View Full Code Here

            // wtptXYZ -> wtptxy
            final float[] wtptxy = XYZ2xy(wtptXYZ);
            whitePointTemperature = CCTX(wtptxy[0]);
            W = W(whitePointTemperature, Cxy);

            RGBToXYZMat = new Matrix (new float[][] {
                mul(W[0] / Zr[1], Zr),
                mul(W[1] / Zg[1], Zg),
                mul(W[2] / Zb[1], Zb)
            }).transpose().getArrayFloat();

            XYZToRGBMat = new Matrix(RGBToXYZMat).inverse().getArrayFloat();
        }
View Full Code Here

            return strip(t);
        }

        public double[][] toRGB(int dataType) {
            double[][] t = scaleTransform(getTransform(), dataType);
            return strip(new Matrix(t).inverse().getArray());
        }
View Full Code Here

        /* compute eigen vectors for 3*3 matrix */

        double[] m = {xx, xy, xz, xy, yy, yz, xz, yz, zz};

        Matrix matrix = new Matrix(m, 3);

        EigenvalueDecomposition ed = matrix.eig();

        double x1 = ed.getV().get(0, 2);
        double y1 = ed.getV().get(1, 2);
        double z1 = ed.getV().get(2, 2);

View Full Code Here

TOP

Related Classes of Jama.Matrix

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.