because it would not use the front two , and then I need to put a true color converted to grayscale ( single channel ) instead of pseudo- grayscale ( three channels ) , mainly in order to continue to be converted to a binary image subsequent processing. So now I choose this method will become grayscale image .
/**
* 图片去色,返回灰度图片
*
* @param bmpOriginal
* 传入的图片
* @return 去色后的图片
*/
public static Bitmap toGrayscale(Bitmap bmpOriginal) {
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap bmpGrayscale = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
Canvas c = new Canvas(bmpGrayscale);
Paint paint = new Paint();
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(bmpOriginal, 0, 0, paint);
// c.drawBitm
return bmpGrayscale;
}
online Baidu 's Android platform for the grayscale image processing is basically the algorithm, but I looked at the parameters drawBitmap feeling after setSaturation (0) handling seemingly still three channel ah ( do not know the function , seeking to explain , Baidu, can not find a clear explanation ) , and then to ask is this method is converted into grayscale ( single channel ) for you ? ? ? ? ?
brother novice , find you greatly help out .
------ Solution ---------------------------------------- ----
this single figure should be the alpha-8 format picture of it, it can only end Meirenhuida posted .
------ For reference only -------------------------------------- -
now know is alpha-8 format is single picture is just black and white drawing , ah, how to deal with what you really need ?
没有评论:
发表评论