/Users/lyon/j4p/src/j2d/hpp/EnaheFilter.java
|
1 /*
2 * Created by DocJava, Inc.
3 * User: lyon
4 * Date: Feb 28, 2003
5 * Time: 7:44:33 AM
6 */
7 package j2d.hpp;
8
9 import math.RgbStats;
10
11 import java.awt.*;
12
13
14 public class EnaheFilter
15 implements HppFilterInterface {
16 /*
17 short lut[] = tt.getLut();
18 RgbStats rgbStats = new RgbStats(ib.getImage());
19 double averageCmf[] = rgbStats.getAverageCmf();
20 for (short i = 0; i < lut.length; i++)
21 lut[i] = (short) (255 * averageCmf[i]);
22 applyLut(lut);
23 */
24 double averageCmf[] = null;
25 double alpha;
26
27 public EnaheFilter(Image img, double alpha) {
28 this.alpha = alpha;
29 RgbStats rgbStats = new RgbStats(img);
30 this.averageCmf = rgbStats.getAverageCmf();
31 }
32
33 public short getR(int r) {
34 return
35 getEnauhe(r);
36 }
37
38 private short getEnauhe(int r) {
39 short v = (short)
40 (255 * (-Math.log(1.0 - averageCmf[r]) / alpha));
41 if (v < 0) return v;
42 if (v > 255) return 255;
43 return v;
44 }
45
46 public short getG(int g) {
47 return getR(g);
48 }
49
50 public short getB(int b) {
51 return getR(b);
52 }
53
54 }
55