@@ -0,0 +1,1935 @@
+/*%0A * Copyright 2014 Fraunhofer IGD%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage algorithms.quality;%0A%0Aimport java.util.Locale;%0Aimport java.util.Random;%0A%0Aimport algorithms.MedianDivergenceComputer;%0Aimport algorithms.sampling.EvenDistributedDistancePoints;%0Aimport colormaps.Colormap2D;%0Aimport static java.lang.Math.log;%0A%0A/**%0A * Represents the color appearance to value divergence ratio as a quality measure.%0A * %0A * Note: Without caching, as is now, this is pretty expensive.%0A * %0A * @author Simon Thum%0A */%0Apublic class ColorAppearanceDivergence implements ColormapQuality %7B%0A%09%0A%09double quantile;%0A%09%0A%09public ColorAppearanceDivergence(double quantile) %7B%0A%09%09super();%0A%09%09this.quantile = quantile;%0A%09%7D%0A%0A%09private String quantileName() %7B%0A%09%09if (quantile == 0.5)%0A%09%09%09return %22median%22;%0A%09%09else return String.format(Locale.ENGLISH, %22%25.1f-quant.%22, quantile);%0A%09%7D%0A%0A%09@Override%0A%09public double getQuality(Colormap2D colormap2d) %7B%0A%09%09MedianDivergenceComputer comp = MedianDivergenceComputer.fromSamplingStrategy(colormap2d, new EvenDistributedDistancePoints(new Random(123), 10000));%0A%09%09return (log(comp.getQuantile(0.9))-log(comp.getQuantile(0.9))) / log(2);%0A%09%7D%0A%0A%09@Override%0A%09public String getName() %7B%0A%09%09return %22Color div. (%22 + quantileName() + %22)%22;%0A%09%7D%0A%0A%09@Override%0A%09public String getDescription() %7B%0A%09%09return %22The color appearance to value divergence in powers of%22%0A%09%09%09%09+ %22 two between upper and lower bound; higher values are worse.%22;%0A%09%7D%0A%0A%7D%0A

add new quality measure