All Downloads are FREE. Search and download functionalities are using the official Maven repository.

icc.lut.LookUpTableFPInterp Maven / Gradle / Ivy

Go to download

Fork of jpeg2k code from https://code.google.com/p/jj2000/. This is a dependency for support of compression in Grib2 files in netCDF-java and TDS. We welcome bug fixes and other contributions to this code.

The newest version!
/*****************************************************************************
 *
 * $Id: LookUpTableFPInterp.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
 *
 * Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
 * $Date $
 *****************************************************************************/

package icc.lut;

import icc .tags.ICCCurveType;

/**
 * An interpolated floating point lut
 * 
 * @version	1.0
 * @author	Bruce A.Kern
 */
public class LookUpTableFPInterp extends LookUpTableFP {     
    
    /**
     * Create an abbreviated string representation of a 16 bit lut.
     * @return the lut as a String
     */
    public String toString () {
        StringBuffer 
            rep = new StringBuffer ("[LookUpTable32 ")
                .append(" nentries= " + lut.length);
        return rep.append("]").toString(); }

    /**
     * Construct the lut from the curve data
     *   @oaram  curve the data
     *   @oaram  dwNumInput the lut size
     */
    public LookUpTableFPInterp (
                 ICCCurveType curve,   // Pointer to the curve data            
                 int dwNumInput       // Number of input values in created LUT
                 ) {
        super (curve, dwNumInput);

        int    dwLowIndex, dwHighIndex;		    // Indices of interpolation points
        double dfLowIndex, dfHighIndex;			// FP indices of interpolation points
        double dfTargetIndex;					// Target index into interpolation table
        double dfRatio;							// Ratio of LUT input points to curve values
        double dfLow, dfHigh;					// Interpolation values
	
        dfRatio = (double)(curve.nEntries-1) / (double)(dwNumInput-1);   

        for (int i = 0; i < dwNumInput; i++) {
            dfTargetIndex = (double) i * dfRatio;
            dfLowIndex    = Math.floor(dfTargetIndex);
            dwLowIndex    = (int) dfLowIndex;
            dfHighIndex   = Math.ceil(dfTargetIndex);
            dwHighIndex   = (int) dfHighIndex;   
            if (dwLowIndex == dwHighIndex)  lut[i] = (float) ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
            else {  
                dfLow  = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
                dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
                lut[i]  = (float) (dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex)); }}}

    /* end class LookUpTableFPInterp */ }


















© 2015 - 2025 Weber Informatics LLC | Privacy Policy