I still do not know how to use OpenCV NDK and Android platforms (according to installation tutorial http://underthehood.blog.51cto.com/2531780/670169 installed on, Cygwin can be used, $ NDK / ndk-build command also can be used, but a running program is not open), if seniors know how to install and use these two, then please guide us be grateful.
Because not use the first two, and then I need to put a true color is converted to grayscale (single channel) instead of pseudo-grayscale (three channels), mainly in order to continue to convert the binary image for further processing. So I chose this method will become grayscale images.
/ **
* Pictures to color, grayscale images
return*
* @ Param bmpOriginal
* Incoming picture
* @ Return to color the picture
* /
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;
}
Baidu's online Android platform as grayscale image processing is basically the algorithm, but I looked at drawBitmap parameter feeling after setSaturation (0) treatment is still seemingly three-channel ah (this function do not understand, seeking to explain , Baidu, could not find a clear explanation), and then ask is this way is converted to grayscale (single channel) it? ? ? ? ?
Brother rookie, seeking the help you greatly.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Picture format is now known to be the single-channel alpha-8 is just black and white map, ah, how to deal with what you really need?
Reply:
This figure should be the single-channel image alpha-8 format it, if only knot Meirenhuida posted.
No comments:
Post a Comment