java.awt.image.ShortLookupTable Java Examples

The following examples show how to use java.awt.image.ShortLookupTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColorBalance.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }

    var rgbLookup = new LookupHelper(cr, mg, yb, affect.getValue())
            .getLookup();

    var filterOp = new FastLookupOp(
            (ShortLookupTable) rgbLookup.getLookupOp());

    filterOp.filter(src, dest);

    return dest;
}
 
Example #2
Source File: SegmenterFacade.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: ApplicationFrame.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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)));
}
 
Example #4
Source File: Sprite.java    From ChatGameFontificator with The Unlicense 5 votes vote down vote up
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);
}
 
Example #5
Source File: Posterize.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BufferedImage doTransform(BufferedImage src, BufferedImage dest) {
    int numRedLevels = redLevels.getValue();
    int numGreenLevels = greenLevels.getValue();
    int numBlueLevels = blueLevels.getValue();
    var rgbLookup = new RGBLookup();
    rgbLookup.initFromPosterize(numRedLevels, numGreenLevels, numBlueLevels);

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

    return dest;
}
 
Example #6
Source File: ExtractChannel.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: Levels.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BufferedImage transform(BufferedImage src, BufferedImage dest) {

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

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

    return dest;
}
 
Example #8
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForRemoveRed() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #9
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForOnlyRed() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #10
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForRemoveGreen() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #11
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForOnlyGreen() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #12
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForRemoveBlue() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getDefaultMapping();
    lookupData[1] = getDefaultMapping();
    lookupData[2] = getNullMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #13
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static LookupTable createLookupForOnlyBlue() {
    short[][] lookupData = new short[3][256];
    lookupData[0] = getNullMapping();
    lookupData[1] = getNullMapping();
    lookupData[2] = getDefaultMapping();
    return new ShortLookupTable(0, lookupData);
}
 
Example #14
Source File: LookupFactory.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #15
Source File: Photo.java    From javaanpr with Educational Community License v2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: FastLookupOp.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public FastLookupOp(ShortLookupTable lut) {
    this.lut = lut;
}