Java BufferedImage Filter thresholdFilter(int threshholdLevel, BufferedImage image)

Here you can find the source of thresholdFilter(int threshholdLevel, BufferedImage image)

Description

Create the filter to execute a threshold setting on the color component values.

License

Open Source License

Declaration

public static BufferedImage thresholdFilter(int threshholdLevel, BufferedImage image) 

Method Source Code

//package com.java2s;
/*/*from w  w  w. j av a  2  s  .  co  m*/
 * $Id: PixelUtil.java,v 1.3 2007/01/29 09:08:46 eiki Exp $ Created on May 29,
 * 2006
 * 
 * Copyright (C) 2006 Idega Software hf. All Rights Reserved.
 * 
 * This software is the proprietary information of Idega hf. Use is subject to
 * license terms.
 */

import java.awt.image.BufferedImage;
import java.awt.image.LookupOp;
import java.awt.image.LookupTable;

import java.awt.image.ShortLookupTable;

public class Main {
    /**
     * Create the filter to execute a threshold setting on the color component
     * values.
     */
    public static BufferedImage thresholdFilter(int threshholdLevel, BufferedImage image) {
        short[] threshold = new short[256];
        for (int i = threshholdLevel; i < 256; i++)
            threshold[i] = (short) i;
        LookupTable threshold_table = new ShortLookupTable(0, threshold);
        LookupOp threshold_op = new LookupOp(threshold_table, null);
        return threshold_op.filter(image, image);
    }
}

Related

  1. filterMedian(BufferedImage img)
  2. filterScale(BufferedImage img, float ratio)
  3. filterSmooth(BufferedImage img)
  4. filterThreshold(BufferedImage img, int threshold)
  5. horizontalFilter(BufferedImage bufImg, int startX, int stopX, int start, int stop, int y, double[] pContrib)
  6. verticalFiltering(BufferedImage pbImage, int iOutH)