Java 类java.awt.image.ShortLookupTable 实例源码

项目:iSeleda    文件:ColorBalance.java   
@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    float cr = cyanRed.getValueAsFloat();
    float mg = magentaGreen.getValueAsFloat();
    float yb = yellowBlue.getValueAsFloat();

    if ((cr == 0) && (mg == 0) && (yb == 0)) {
        return src;
    }

    int affect = affectParam.getValue();

    RGBLookup rgbLookup = new LookupCalculator(cr, mg, yb, affect).getLookup();

    BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) rgbLookup.getLookupOp());
    filterOp.filter(src, dest);

    return dest;
}
项目:SmartTokens    文件:GUIUtils.java   
/**
 * For testing lookup tables
 */
public static Image toInverseVideo(Image source) {
    //
    BufferedImage src = new BufferedImage(source.getWidth(null), source
            .getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics g = src.getGraphics();
    g.drawImage(source, 0, 0, null);
    //
    short[][] lookup = new short[4][256];
    for (int c = 0; c < 4; c++) {
        for (short b = 0; b < 256; b++) {
            if (c == 3)
                lookup[c][b] = b;
            else
                lookup[c][b] = (short)(255 - b);
        }
    }
    LookupTable table = new ShortLookupTable(0, lookup);
    LookupOp op = new LookupOp (table, null);
    return op.filter(src, null);
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Corrección gamma. Si 0 menor_que gamma menor_que 1 ilumina, si
 * gamma_mayor_que 1 oscurece
 *
 * @param cteA double
 * @param gamma double
 * @return LookupTable
 */
public static LookupTable gammaCorrection(double cteA, double gamma) {
    if (gamma <= 0) {
        return null;
    }
    // K: constante de normalización 
    double K = ((double) MAX_LEVEL) / (cteA * Math.pow(((double) MAX_LEVEL), gamma));
    short lt[] = new short[MAX_LEVEL + 1];
    for (int l = 0; l <= MAX_LEVEL; l++) {
        lt[l] = (short) (K * cteA * Math.pow((double) l, gamma));
    }
    ShortLookupTable slt = new ShortLookupTable(0, lt);
    if (ECHO) {
        plot(lt);
    }
    return slt;
}
项目:geneaquilt    文件:GUIUtils.java   
/**
 * For testing lookup tables
 */
public static Image toInverseVideo(Image source) {
    //
    BufferedImage src = new BufferedImage(source.getWidth(null), source
            .getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics g = src.getGraphics();
    g.drawImage(source, 0, 0, null);
    //
    short[][] lookup = new short[4][256];
    for (int c = 0; c < 4; c++) {
        for (short b = 0; b < 256; b++) {
            if (c == 3)
                lookup[c][b] = b;
            else
                lookup[c][b] = (short)(255 - b);
        }
    }
    LookupTable table = new ShortLookupTable(0, lookup);
    LookupOp op = new LookupOp (table, null);
    return op.filter(src, null);
}
项目:orbit-image-analysis    文件:SegmenterFacade.java   
private static BufferedImage invertImage(final BufferedImage src) {
  final int w = src.getWidth();
  final int h = src.getHeight();
  final BufferedImage dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);

  final BufferedImageOp invertOp = new LookupOp(new ShortLookupTable(0, invertTable), null);
  return invertOp.filter(src, dst);
}
项目:iSeleda    文件:Posterize.java   
@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    int numLevels = levels.getValue();
    RGBLookup rgbLookup = new RGBLookup();
    rgbLookup.initFromPosterize(numLevels);

    BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) rgbLookup.getLookupOp());
    filterOp.filter(src, dest);

    return dest;
}
项目:iSeleda    文件:ExtractChannel.java   
private static BufferedImage colorExtractChannel(BufferedImage src, BufferedImage dest, int channel) {
    LookupTable lookupTable;

    switch (channel) {
        case RED_CHANNEL:
            lookupTable = LookupFactory.createLookupForOnlyRed();
            break;
        case REMOVE_RED_CHANNEL:
            lookupTable = LookupFactory.createLookupForRemoveRed();
            break;
        case GREEN_CHANNEL:
            lookupTable = LookupFactory.createLookupForOnlyGreen();
            break;
        case REMOVE_GREEN_CHANNEL:
            lookupTable = LookupFactory.createLookupForRemoveGreen();
            break;
        case BLUE_CHANNEL:
            lookupTable = LookupFactory.createLookupForOnlyBlue();
            break;
        case REMOVE_BLUE_CHANNEL:
            lookupTable = LookupFactory.createLookupForRemoveBlue();
            break;
        default:
            throw new IllegalStateException("should not het here");
    }

    BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) lookupTable);
    filterOp.filter(src, dest);
    return dest;
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForRemoveRed() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForOnlyRed() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForRemoveGreen() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForOnlyGreen() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForRemoveBlue() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupForOnlyBlue() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:LookupFactory.java   
public static LookupTable createLookupFrom3Arrays(short[] redMappings, short[] greenMappings, short[] blueMappings) {
    short[][] lookupData = new short[3][256];
    lookupData[0] = redMappings;
    lookupData[1] = greenMappings;
    lookupData[2] = blueMappings;
    return new ShortLookupTable(0, lookupData);
}
项目:iSeleda    文件:DynamicLookupFilter.java   
@Override
public BufferedImage transform(BufferedImage src, BufferedImage dest) {

    if (rgbLookup == null) {
        throw new IllegalStateException("rgbLookup not initialized in DynamicLookupOp");
    }

    BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) rgbLookup.getLookupOp());
    filterOp.filter(src, dest);

    return dest;
}
项目:filthy-rich-clients    文件:ApplicationFrame.java   
private void buildLookupOpTab(JTabbedPane tabbedPane) {
    BufferedImage dstImage = null;
    short[] data = new short[256];
    for (int i = 0; i < 256; i++) {
        data[i] = (short) (255 - i);
    }
    LookupTable lookupTable = new ShortLookupTable(0, data);
    LookupOp op = new LookupOp(lookupTable, null);
    dstImage = op.filter(sourceImage, null);

    tabbedPane.add("Lookup", new JLabel(new ImageIcon(dstImage)));
}
项目:ChatGameFontificator    文件:Sprite.java   
private void setupSwap()
{
    short[][] lookupArray = new short[4][256];
    for (int i = 0; i < lookupArray.length; i++)
    {
        for (short c = 0; c < lookupArray[i].length; c++)
        {
            lookupArray[i][c] = c;
        }
    }
    swapTable = new ShortLookupTable(0, lookupArray);
    swapOp = new LookupOp(swapTable, null);
}
项目:ChainReactionClone    文件:Colorizer.java   
/**
 * @see <a href="http://stackoverflow.com/questions/23763/colorizing-images-in-java">Colorizing images in Java</a>
 * @see <a href="http://stackoverflow.com/questions/7621774/whats-the-appropriate-way-to-colorize-a-grayscale-image-with-transparency-in-ja">What's the appropriate way to colorize a grayscale image with transparency in Java?</a>
 *
 * @param colors An array, {R, G, B}
 *
 * @return
 */
protected static LookupOp createColorizeOp(int[] colors) {//short R1, short G1, short B1
    short[] alpha = new short[256];
    short[] red = new short[256];
    short[] green = new short[256];
    short[] blue = new short[256];

    //int Y = 0.3*R + 0.59*G + 0.11*B
    for (short i = 255; i < 256; i++) {//keep white white
        alpha[i] = i;
        red[i] = i;
        green[i] = i;
        blue[i] = i;
    }
    //red[255] = (short) 0;
    //green[255] = (short) 0;
    //blue[255] = (short) 0;
    for (short i = 0; i < 255; i++) {
        alpha[i] = i;
        red[i] = (short) (colors[0] * (float) i / 255.0);
        green[i] = (short) (colors[1] * (float) i / 255.0);
        blue[i] = (short) (colors[2] * (float) i / 255.0);
    }

    short[][] data = new short[][]{
        red, green, blue, alpha
    };

    LookupTable lookupTable = new ShortLookupTable(0, data);
    return new LookupOp(lookupTable, null);
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función negativo
 */
public static LookupTable negativeFuction(){
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++) 
        lt[l] = (short)(MAX_LEVEL-l);     
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función "S". Util para contrastar una imagen 
 */
public static LookupTable sFuction(double m, double e){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(1.0/(1.0+Math.pow(m/((double)MAX_LEVEL),e)));
    short lt[] = new short[MAX_LEVEL+1];
    lt[0]=0;
    for (int l=1; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*(1.0/(1.0+Math.pow(m/(float)l,e))));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función logaritmo. Util para iluminar una imagen
 */
public static LookupTable logarithmFuction(){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.log(1.0+((double)MAX_LEVEL));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.log(1.0+(double)l));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función potencia. Util para oscurecer una imagen
 */
public static LookupTable powerFuction(double n){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.pow(((double)MAX_LEVEL),n);
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.pow((double)l,n));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Corrección gamma. Si 0<gamma<1 ilumina, si gamma>1 oscurece 
 */
public static LookupTable gammaCorrection(double cteA, double gamma){
    if(gamma<=0) return null;
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(cteA*Math.pow(((double)MAX_LEVEL),gamma));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*cteA*Math.pow((double)l,gamma));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función negativo
 */
public static LookupTable negativeFuction(){
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++) 
        lt[l] = (short)(MAX_LEVEL-l);     
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función "S". Util para contrastar una imagen 
 */
public static LookupTable sFuction(double m, double e){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(1.0/(1.0+Math.pow(m/((double)MAX_LEVEL),e)));
    short lt[] = new short[MAX_LEVEL+1];
    lt[0]=0;
    for (int l=1; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*(1.0/(1.0+Math.pow(m/(float)l,e))));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función logaritmo. Util para iluminar una imagen
 */
public static LookupTable logarithmFuction(){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.log(1.0+((double)MAX_LEVEL));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.log(1.0+(double)l));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función potencia. Util para oscurecer una imagen
 */
public static LookupTable powerFuction(double n){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.pow(((double)MAX_LEVEL),n);
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.pow((double)l,n));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Corrección gamma. Si 0<gamma<1 ilumina, si gamma>1 oscurece 
 */
public static LookupTable gammaCorrection(double cteA, double gamma){
    if(gamma<=0) return null;
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(cteA*Math.pow(((double)MAX_LEVEL),gamma));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*cteA*Math.pow((double)l,gamma));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 *
 * @return LookupTable
 */
public static LookupTable negativeFuction() {
    short lt[] = new short[MAX_LEVEL + 1];
    for (int l = 0; l <= MAX_LEVEL; l++) {
        lt[l] = (short) (MAX_LEVEL - l);
    }
    ShortLookupTable slt = new ShortLookupTable(0, lt);
    if (ECHO) {
        plot(lt);
    }
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 *
 * Función "S". Util para contrastar una imagen
 *
 * @param m dobuel
 * @param e double
 * @return LookupTable
 */
public static LookupTable sFuction(double m, double e) {
    // K: constante de normalización 
    double K = ((double) MAX_LEVEL) / (1.0 / (1.0 + Math.pow(m / ((double) MAX_LEVEL), e)));
    short lt[] = new short[MAX_LEVEL + 1];
    lt[0] = 0;
    for (int l = 1; l <= MAX_LEVEL; l++) {
        lt[l] = (short) (K * (1.0 / (1.0 + Math.pow(m / (float) l, e))));
    }
    ShortLookupTable slt = new ShortLookupTable(0, lt);
    if (ECHO) {
        plot(lt);
    }
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función logaritmo. Util para iluminar una imagen
 *
 * @return LookupTable
 */
public static LookupTable logarithmFuction() {
    // K: constante de normalización 
    double K = ((double) MAX_LEVEL) / Math.log(1.0 + ((double) MAX_LEVEL));
    short lt[] = new short[MAX_LEVEL + 1];
    for (int l = 0; l <= MAX_LEVEL; l++) {
        lt[l] = (short) (K * Math.log(1.0 + (double) l));
    }
    ShortLookupTable slt = new ShortLookupTable(0, lt);
    if (ECHO) {
        plot(lt);
    }
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función potencia. Util para oscurecer una imagen
 *
 * @param n double
 * @return LookupTable
 */
public static LookupTable powerFuction(double n) {
    // K: constante de normalización 
    double K = ((double) MAX_LEVEL) / Math.pow(((double) MAX_LEVEL), n);
    short lt[] = new short[MAX_LEVEL + 1];
    for (int l = 0; l <= MAX_LEVEL; l++) {
        lt[l] = (short) (K * Math.pow((double) l, n));
    }
    ShortLookupTable slt = new ShortLookupTable(0, lt);
    if (ECHO) {
        plot(lt);
    }
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función negativo
 */
public static LookupTable negativeFuction(){
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++) 
        lt[l] = (short)(MAX_LEVEL-l);     
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función "S". Util para contrastar una imagen 
 */
public static LookupTable sFuction(double m, double e){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(1.0/(1.0+Math.pow(m/((double)MAX_LEVEL),e)));
    short lt[] = new short[MAX_LEVEL+1];
    lt[0]=0;
    for (int l=1; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*(1.0/(1.0+Math.pow(m/(float)l,e))));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función logaritmo. Util para iluminar una imagen
 */
public static LookupTable logarithmFuction(){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.log(1.0+((double)MAX_LEVEL));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.log(1.0+(double)l));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Función potencia. Util para oscurecer una imagen
 */
public static LookupTable powerFuction(double n){
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/Math.pow(((double)MAX_LEVEL),n);
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*Math.pow((double)l,n));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:Sistemas-Multimedia    文件:LookupTableProducer.java   
/**
 * Corrección gamma. Si 0<gamma<1 ilumina, si gamma>1 oscurece 
 */
public static LookupTable gammaCorrection(double cteA, double gamma){
    if(gamma<=0) return null;
    // K: constante de normalización 
    double K = ((double)MAX_LEVEL)/(cteA*Math.pow(((double)MAX_LEVEL),gamma));
    short lt[] = new short[MAX_LEVEL+1];
    for (int l=0; l<=MAX_LEVEL; l++)
      lt[l] = (short)(K*cteA*Math.pow((double)l,gamma));
    ShortLookupTable slt = new ShortLookupTable(0,lt);
    if(ECHO) plot(lt);
    return slt;
}
项目:javaanpr    文件:Photo.java   
static void thresholding(BufferedImage bi) { // TODO Optimize
    short[] threshold = new short[256];
    for (short i = 0; i < 36; i++) {
        threshold[i] = 0;
    }
    for (short i = 36; i < 256; i++) {
        threshold[i] = i;
    }
    BufferedImageOp thresholdOp = new LookupOp(new ShortLookupTable(0, threshold), null);
    thresholdOp.filter(bi, bi);
}
项目:XPressOnTechnologies    文件:ImageUtils.java   
public static BufferedImage brightenImage(BufferedImage srcImg) {
    short brighten[] = new short[256];
    for (int i = 0; i < 256; i++) {
        short pixelValue = (short) (i + 10);
        if (pixelValue > 255)
            pixelValue = 255;
        else if (pixelValue < 0)
            pixelValue = 0;
        brighten[i] = pixelValue;
    }
    LookupTable lookupTable = new ShortLookupTable(0, brighten);
    return applyFilter(lookupTable, srcImg);
}
项目:iSeleda    文件:FastLookupOp.java   
public FastLookupOp(ShortLookupTable lookupTable) {
    this.lookupTable = lookupTable;
}