001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009 010package imagingbook.pub.color.image; 011 012 013public class XYZscalingAdaptation extends ChromaticAdaptation { 014 015 public XYZscalingAdaptation(float[] white1, float[] white2) { 016 super(white1, white2); 017 } 018 019 public XYZscalingAdaptation(Illuminant illum1, Illuminant illum2) { 020 this(illum1.getXyzFloat(), illum2.getXyzFloat()); 021 } 022 023 public float[] apply (float[] XYZ1) { 024 float[] W1 = this.white1; 025 float[] W2 = this.white2; 026 float[] XYZ2 = new float[3]; 027 XYZ2[0] = XYZ1[0] * W2[0] / W1[0]; 028 XYZ2[1] = XYZ1[1] * W2[1] / W1[1]; 029 XYZ2[2] = XYZ1[2] * W2[2] / W1[2]; 030 return XYZ2; 031 } 032 033}