psychWithJava
Class CLUT8

java.lang.Object
  extended by psychWithJava.CLUT8

public class CLUT8
extends java.lang.Object

Provides methods to perform lookup operations. User provides the lookup table in a file, methods of this class can report the luminance of a pixel, and can find the pixel whose luminance is closest to the required luminance.


Constructor Summary
CLUT8(double[] table)
           
CLUT8(java.lang.String filename)
          constructs a LUT8 object.
 
Method Summary
 double getMaxLum()
          returns the maximum available luminance
 int lum2Pix(double lum)
          Returns the pixel whose luminance is CLOSEST to the required luminance.
 int lum2Pix(int lum)
          Returns the pixel whose luminance is CLOSEST to the required luminance.
static void main(java.lang.String[] args)
           
 double pix2Lum(int pixel)
          Returns the RELATIVE luminance of the given pixel.
 void setClut(double[] table)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CLUT8

public CLUT8(java.lang.String filename)
      throws java.lang.IllegalArgumentException
constructs a LUT8 object. File "filename" contains the 256 lines of luminance values for each pixel from 255 to 0 in descending order. The file may contain the absolute luminance values, but LUT8 stores relative values and its methods always work with the relative values between 0.0 and 255.0.

Parameters:
filename - the name of the file containing pixel-luminance value pairs
Throws:
java.lang.IllegalArgumentException

CLUT8

public CLUT8(double[] table)
      throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

setClut

public void setClut(double[] table)

getMaxLum

public double getMaxLum()
returns the maximum available luminance

Returns:
maximum luminance

lum2Pix

public int lum2Pix(double lum)
Returns the pixel whose luminance is CLOSEST to the required luminance. This is a slower but more precise lookup for real (non-whole) values between 0 and 255

Parameters:
lum - required Luminance (real number, i.e. double)
Returns:
pixel whose luminance is the closest to required Luminance

lum2Pix

public int lum2Pix(int lum)
Returns the pixel whose luminance is CLOSEST to the required luminance. This is a faster lookup for whole numbers between 0 and 255.

Parameters:
lum - required Luminance (whole number, integer)
Returns:
pixel whoe luminance is the closest to required Luminance

pix2Lum

public double pix2Lum(int pixel)
Returns the RELATIVE luminance of the given pixel. The relative value is between 0 and 255 (not 0 and 1)

Parameters:
pixel - whose luminance is sought
Returns:
Luminance8 of the pixel

main

public static void main(java.lang.String[] args)