码迷,mamicode.com
首页 > 移动开发 > 详细

android图像处理

时间:2015-05-25 16:39:50      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:图像处理

<h4>图像分析之RGBA模型</h4>
1.色调/色相--物体传递的颜色
ColorMatrix hueMatrix=new ColorMtrix();
hueMatrix.setRotate(0,hue);
hueMatrix.setRotate(1,hue);
hueMatrix.setRotate(2.hue);
2.饱和度--颜色的纯度,从(0)到100%饱和来进行描述
ColorMatrix saturationMatrix=new ColorMatrix();
saturationMatrix.setSaturation(saturation);
3.亮度/明度--颜色相对的明暗程度
ColorMatrix lumMatrix=new ColorMatrix();
lumMatrix.setScale(lum,lum,lun,1);
下面看主要代码
public class MainActivity extends Activity implements SeekBar.OnSeekBarChangeListener{


private ImageView imageView;
private SeekBar seekBar1,seekBar2,seekBar3;
private static int MAX=255;
private static int IN=127;
private MediaPlayer player;
float a,b,c;
private Bitmap bitmap;
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.g);
        imageView=(ImageView)findViewById(R.id.imageView);
        seekBar1=(SeekBar)findViewById(R.id.seekBar1);
        seekBar2=(SeekBar)findViewById(R.id.seekBar2);
        seekBar3=(SeekBar)findViewById(R.id.seekBar3);
        seekBar1.setOnSeekBarChangeListener(this);
        seekBar2.setOnSeekBarChangeListener(this);
        seekBar3.setOnSeekBarChangeListener(this);
        seekBar1.setMax(MAX);
        seekBar2.setMax(MAX);
        seekBar3.setMax(MAX);
        seekBar1.setProgress(IN);
        seekBar2.setProgress(IN);
        seekBar3.setProgress(IN);
        imageView.setImageBitmap(bitmap);
        player=MediaPlayer.create(this, R.raw.);
        player.start();
        }


  @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }


@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
switch(arg0.getId()){
case R.id.seekBar1:
a=(arg1-IN)*1.0F/IN*180;
break;
case R.id.seekBar2:
b=arg1*1.0F/IN;
break;
case R.id.seekBar3:
c=arg1*1.0F/IN;
break;
}
imageView.setImageBitmap(new ImageHelper().handleImageView(bitmap, a, b, c));
}




class ImageHelper {


public static Bitmap handleImageView(Bitmap bm,float bug,float b,float c){

Bitmap bm1=Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas=new Canvas(bm1);
Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
ColorMatrix hm=new ColorMatrix();
hm.setRotate(0, bug);
hm.setRotate(1, bug);
hm.setRotate(2, bug);
ColorMatrix sm=new ColorMatrix();
sm.setSaturation(b);
ColorMatrix lm=new ColorMatrix();
lm.setScale(c, c, c, 1);
ColorMatrix Imagem=new ColorMatrix();
Imagem.postConcat(hm);
Imagem.postConcat(sm);
Imagem.postConcat(lm);
paint.setColorFilter(new ColorMatrixColorFilter(Imagem));
canvas.drawBitmap(bm, 0, 0, paint);

return bm1;

}
}


}

android图像处理

标签:图像处理

原文地址:http://blog.csdn.net/xiyou_android/article/details/45970251

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