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-2023 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit https://imagingbook.com for additional details. 008 ******************************************************************************/ 009 010package imagingbook.common.color.adapt; 011 012import imagingbook.common.color.cie.CieUtils; 013 014/** 015 * Interface to be implemented by chromatic adaptation transforms. 016 * 017 * @author WB 018 */ 019public interface ChromaticAdaptation { 020 021 /** 022 * Transforms the specified XYZ source color coordinates to target coordinates. The specified color coordinates are 023 * interpreted relative to (source) white point (W1). Returns a new color adapted to (target) white point W2. 024 * 025 * @param xyz the original color point w.r.t. the source white point (W1) 026 * @return the adapted color w.r.t. the target white point (W2). 027 */ 028 public float[] applyTo(float[] xyz); 029 030 /** 031 * Double version of {@link #applyTo(float[])}. 032 * 033 * @param xyz the original color point w.r.t. the source white point (W1) 034 * @return the adapted color w.r.t. the target white point (W2). 035 */ 036 public double[] applyTo(double[] xyz); 037 038 /** 039 * Transforms the specified xy source color coordinates to target xy coordinates. The specified color coordinates are 040 * interpreted relative to (source) white point (W1). Returns xy color coordinates adapted to (target) white point W2. 041 * @param x x-coordinate 042 * @param y y-coordinate 043 * @return the adapted color w.r.t. the target white point (W2). 044 */ 045 public default double[] applyTo(double x, double y) { 046 double[] XYZA = CieUtils.xyToXYZ(x, y); 047 double[] XYZB = applyTo(XYZA); 048 return CieUtils.XYZToxy(XYZB); 049 } 050 051}