简体   繁体   中英

How can i segment an image using opencv4android

I am developing an application on the android platform. The app basically needs to capture an image using the camera, and then analyse the captured image to see where does red and blue color ends and the next step is to make a contour arround twi shape cirle and triangle.(already done ) Now i Have to move to the next step : segmentation Can you help me how to segment this images. Any ideas?

Assuming c is your contour:

Rect roi = Imgproc.boundingRect(c);
Mat newMat = mRgba.submat(roi);
Bitmap bmp1 = Bitmap.createBitmap(newMat.width(), newMat.height(),
            Bitmap.Config.ARGB_8888);
Utils.matToBitmap(newMat, bmp1);

bmp1 should then hold the image you want.

This will however give you a rectangular image that shows the bounding area of your original object, so if it was a circle you have detected, you will get the circle plus all the other parts of the image contained in the bounding box. If you just want the detected object and have the rest of the content as transparent then that is a slightly harder problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM