我想将位图转换为灰色位图:
private Bitmap toGray(Bitmap bitmap) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
IplImage iplImage = IplImage.create(w, h, IPL_DEPTH_8U, 4);
bitmap.copyPixelsToBuffer(iplImage.getByteBuffer());
IplImage iplImageDest = IplImage.create(w, h, IPL_DEPTH_8U, 1);
cvCvtColor(iplImage , iplImageDest , CV_RGB2GRAY);
return toBitmap(iplImageDest);
}
private static Bitmap toBitmap(IplImage iplImage) {
int w = iplImage.width();
int h = iplImage.height();
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ALPHA_8);
bitmap.copyPixelsFromBuffer(iplImage.getByteBuffer());
return bitmap;
}
输出: https://i.stack.imgur.com/btNDH.png
我得到这个重复的图片我做错了什么?