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 ******************************************************************************/ 009package imagingbook.common.color.gamma; 010 011/** 012 * Interface to be implemented by gamma correction classes. All in/out component values are assumed to be in [0,1]. 013 * Implementing classes must at least define a {@code double} version of the required methods but are free to override 014 * the associated {@code float} versions. 015 * 016 * @author WB 017 * @version 2022/11/16 018 */ 019public interface GammaMapping { 020 021 /** 022 * Forward Gamma mapping (from linear to non-linear component values). 023 * 024 * @param a linear component value in [0,1] 025 * @return the gamma-corrected (non-linear) component value 026 */ 027 public double applyFwd(double a); 028 029 /** 030 * Float version of {@link #applyFwd(double)} 031 * 032 * @param a linear component value in [0,1] 033 * @return the gamma-corrected (non-linear) component value 034 */ 035 public default float applyFwd(float a) { 036 return (float) applyFwd((double) a); 037 } 038 039 /** 040 * Inverse Gamma mapping (from non-linear to linear component values). 041 * 042 * @param b non-linear (Gamma-corrected) component value in [0,1] 043 * @return the linear component value 044 */ 045 public double applyInv(double b); 046 047 /** 048 * Float version of {@link #applyInv(double)} 049 * @param b non-linear (Gamma-corrected) component value in [0,1] 050 * @return the linear component value 051 */ 052 public default float applyInv(float b) { 053 return (float) applyInv((double) b); 054 } 055 056}