码迷,mamicode.com
首页 > 其他好文 > 详细

图像像素基本操作——自然系列滤镜

时间:2018-01-31 20:08:33      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:void   loading   ==   pixel   int   error   vax   滤镜   abstract   

主要代码如下:
package chapter5;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**

  • Created by LENOVO on 18-1-30.
    */
    public class LvJingFilter extends AbstractBufferedImageOp {
    int[] fogLookUp = new int[257];//雾化风格颜色查找表
    int[] rainbowLookup ;
    public LvJingFilter(){

    }
    public BufferedImage filter(BufferedImage src,BufferedImage dest){
    int width = src.getWidth();
    int height = src.getHeight();
    if(dest == null){
    dest = creatCompatibleDestImage(src,null);
    }
    int inpixels[] = new int[width*height];
    int outpixels[] = new int[width*height];
    getRGB(src,0,0,width,height,inpixels);
    int index = 0;
    for(int row=0;row<height;row++){
    int ta = 0,tr = 0,tg = 0,tb = 0;
    for(int col=0;col

    return dest;

    }
    //雾风格颜色查找表//40,41,42,.....127,127,127,....127,128,129,...,255
    public void buildFogLookupTable(){
    //颜色查找表
    int fogLimit = 40;
    for(int i=0; i

    }

    }

    //彩虹风格颜色查找表
    public void buildRainBowLookupTable(){
    java.net.URL imageURL = this.getClass().getResource("rainbow.jpg");
    if(imageURL !=null){
    try {
    BufferedImage image = ImageIO.read(imageURL);
    int width = image.getWidth();
    int height = image.getHeight();
    rainbowLookup = new int[width];
    int[] inPixels = new int[width*height];
    getRGB(image,0,0,width,height,inPixels);
    for(int col=0;col<width;col++){
    rainbowLookup[col] = inPixels[col];
    }
    } catch (IOException e) {
    // e.printStackTrace();
    System.out.println("An error occured when loading the image icon...");
    }
    }

    }
    }
    测试代码同上

图像像素基本操作——自然系列滤镜

标签:void   loading   ==   pixel   int   error   vax   滤镜   abstract   

原文地址:https://www.cnblogs.com/bigdream6/p/8385047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!