2013年9月24日星期二

About the android platform into a grayscale image processing problems

I still do not understand how to use NDK and Android platforms OpenCV ( according http://underthehood.blog.51cto.com/2531780/670169 installed on the installation tutorial , Cygwin can be used , $ NDK/ndk- build command can also be used, but a running program is not open ) , if there are seniors know how to install and use these two , then please guide us be grateful.


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 ?

没有评论:

发表评论