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 012public class RgbGamutChecker { 013 014 static final double lo = -0.01; 015 static final double hi = 1.01; 016 017 public static boolean markOutOfGamutColors = false; 018 019 public static double oGred = 1; // out of gamut replacement values 020 public static double oGgrn = 1; 021 public static double oGblu = 1; 022 023 static int ctr = 0; 024 025 public static void reset() { 026 ctr = 0; 027 } 028 029 public static void increment() { 030 ctr = ctr + 1; 031 } 032 033 public static int getCount() { 034 return ctr; 035 } 036 037 public static boolean checkOutOfGamut(double r, double g, double b) { 038 if (r < lo || r > hi || g < lo || g > hi || b < lo || b > hi) { 039 ctr = ctr + 1; 040 return true; 041 } 042 else { 043 return false; 044 } 045 } 046}