Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 1117

How can I improve the binarization of image in my sample app

$
0
0
I'a practicing in proprocessingiages in android studio and I want to improve the binarihiszation of images in my program, for example i have this image: ![image description](/upfiles/15421044208007355.jpg) and my program is binarizing it to this:![image description](/upfiles/15421045144334361.png) I would like to be able to maintain the horizontal lines(staff lines) for a horizontal line detection. here is the piece of my code for the grayscale and binary: public void convGray(View view) { Mat Rgba = new Mat(); Mat grayMat = new Mat(); Mat imageBW = new Mat(); BitmapFactory.Options o = new BitmapFactory.Options(); o.inDither=false; o.inSampleSize=4; int width = imageBitmap.getWidth(); int height = imageBitmap.getHeight(); grayBitmap = Bitmap.createBitmap(width,height,Bitmap.Config.RGB_565); //bitmap to Mat Utils.bitmapToMat(imageBitmap,Rgba); Imgproc.cvtColor(Rgba,grayMat,Imgproc.COLOR_RGB2GRAY); Imgproc.threshold(grayMat,imageBW,100,255,Imgproc.THRESH_BINARY); Utils.matToBitmap(imageBW,grayBitmap); imageView.setImageBitmap(grayBitmap); }

Viewing all articles
Browse latest Browse all 1117

Trending Articles