⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thresholdingfilter.java

📁 some of the image proceeing samples using java
💻 JAVA
字号:
package image.filter;

import image.EditableImage;
import image.ImagingUtils;

public class ThresholdingFilter extends AbstractFilter {
    
    public ThresholdingFilter(EditableImage image) {
        super(image);
    }
    
    
    public void processFilter() {
        
        int threshold = ((Integer)getParameter("threshold")).intValue();
        
        if (threshold > 0 && threshold <= 255) {
        
            int width = image.getWidth();
            int height = image.getHeight();

            for (int h = 0; h < height; h++) {
                for (int w = 0; w < width; w++) {

                    image.getImage().setRGB(w, h, thresholdPixel(image.getImage().getRGB(w, h), threshold));
                }
            }
        }
    }
    
    private int thresholdPixel(int pixel, int threshold) {
        return ImagingUtils.convertPixel((((ImagingUtils.convertToGrayscale(pixel) & 0x00FF0000) >>> 16) > threshold) ? 255 : 0);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -