欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Android OpenCV 灰度图转化

程序员文章站 2022-04-15 11:29:43
...
package com.tsayq.opencv0;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;

public class OpenCV_0_Activity extends Activity {
	private ImageView imageView;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		imageView = (ImageView) findViewById(R.id.image);
		Mat img = Highgui.imread("/sdcard/Lena.jpg",0);
		Highgui.imwrite("/sdcard/new.JPG", img);
		Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/new.JPG");
		imageView.setImageBitmap(bitmap);

	}
}