I want to make an app, in which I want to take a picture and input x,y axis it will show me corresponding point pixel value from the captured picture .
I don't have any knowledge about image processing well . So, how can I do it ? help me .
答案 0 :(得分:0)
我过去这样做的方法是将图像写入文件系统,然后对其进行解码。不可否认,它有点低效但功能正常。
这需要许多步骤。我建议你仔细阅读documentation。它描述了拍摄图像并将其保存到文件系统的过程,您需要执行之前,您可以执行其余步骤。
接下来,您需要使用BitmapFactory
对图像进行解码,该图像将为您提供Bitmap
的实例,您可以执行各种操作(记录为here)。在此示例中,我使用Color
返回位于(50, 50)
的像素的getPixel()
对象。此示例假定图像的路径为mCurrentPhotoPath
,但应该是保存图像的位置。
private Color getColor() {
// Get the dimensions of the View
int targetW = mImageView.getWidth();
int targetH = mImageView.getHeight();
// Get the dimensions of the bitmap
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
// Determine how much to scale down the image
int scaleFactor = Math.min(photoW/targetW, photoH/targetH);
// Decode the image file into a Bitmap sized to fill the View
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true;
Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
return bitmap.getPixel(50, 50);
}
您可以从此Color
对象获取RGB值,这是我认为您想要做的事情。这可以在Android开发者的Color
对象文档中找到。