android影像處理

來源:互聯網
上載者:User

標籤:影像處理

<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影像處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.