这是我从中读取图像rectangle.jpg
的代码/sdcard
。我想知道像素值(正常,以及 RGB 格式)。我应该使用什么代码来处理它?
package com.idag.edge;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.util.Log;
import android.widget.TextView;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try
{
String path=Environment.getExternalStorageDirectory().getAbsolutePath() +"/rectangle.jpg";
Mat m=Highgui.imread(path,1);
Log.i("Paramenres on matrix", "height "+ m.height()+" width "+ m.width()+" total = "+m.total()+" channels " +m.channels());
System.out.println("element at 0 0 = "+ m.row(0).col(0).nativeObj+" element at 150 150 = "+ m.row(150).col(150).nativeObj);
}
catch(Exception e){
System.err.print("Error in the code");
Log.i("Error in imread", "Error in imread");
}
}
}