Ask Your Question

Hello Friends, How can i create a mask image in opencv and create trimap segments. Please guide its urgent.

asked 2013-12-08 20:03:23 -0500

Joystna gravatar image

updated 2013-12-08 23:01:30 -0500

Hello Friends,

I want to create a mask image and i want to segment it with trimap. and put that mask image on the original image and segment it F & B image. actually i am trying Gracut where i need to create a mask image and segment it and apply it on the original image.

Please guide me with the source code to create mask image and put that on original image. YOur kind help will be highly appriciated.

Thank you in advance.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-12-09 05:39:43 -0500

Haris gravatar image

See OpenCV grab-cut example on Github. You can see OpenCV documentation about grabcut here. Also refer Interactive Foreground Extraction using GrabCut Algorithm.

edit flag offensive delete link more


hello below is my source code but it is not according to exact result because I am not using the mask image . Can anyone help me mask image source it will be highly appreciated.

include <opencv2/core/core.hpp>

include <opencv2/highgui/highgui.hpp>

include <opencv2/imgproc/imgproc.hpp>

include <iostream>

using namespace cv; using namespace std;

int main( ) { // Open another image Mat image; image = cv::imread("2.png");

if(! ) // Check for invalid input
    cout &lt;&lt;  "Could not open or find the image" &lt;&lt; std::endl ;
    return -1;

// define bounding rectangle

// int border = 50; // int border2 = border + border; //cv::Rect rectangle(border,border,image.cols-border2,image.rows-border2); cv::Rect rectangle(20,35,imag

Joystna gravatar imageJoystna ( 2013-12-09 07:25:51 -0500 )edit

Question Tools

1 follower


Asked: 2013-12-08 20:03:23 -0500

Seen: 550 times

Last updated: Dec 09 '13