Re: [javacv] How to Extract Foreground mask Using GrabCut Algorithm

568 views
Skip to first unread message

Samuel Audet

unread,
Jan 26, 2014, 7:40:36 AM1/26/14
to jav...@googlegroups.com
Hello,

On 01/24/2014 08:10 PM, Prakash Parupudi wrote:
> Now how to Extract the Fore Ground mask?
> When i am using cvCompareHistogram it is not working ?so is there
> any method to compare "GC_PR_FGD" and "CV_CMP_EQ" in javacv?if Yes can u
> please Suggest/help me?

It depends on what you want to do. I'm guessing you are looking for the
`cvCmp()` function:
http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#compare
But if you could explain more clearly what you are trying to do, I might
be able to help a bit more...

> And more over after obtaining the Foreground image can i use
> "cvShowImage" to show and
> "cvSaveImage" to save that particular foreground image?

Sure, we can use either of these

Samuel
Message has been deleted

Prakash Parupudi

unread,
Jan 27, 2014, 1:25:19 AM1/27/14
to jav...@googlegroups.com
Here i have attached 3 images. originalImage.jpg is my image ,grabCutImage.jpg is my expected image and i was stuck near Image.jpg( pixels marked as likely foreground).

Now in order to get GrabCutImage.jpg from Image.jpg i need to use CvMatForeground which is used in c++ as below :

 cv::Mat foreground(image.size(),CV_8UC3,cv::Scalar(255,255,255)); 
image.copyTo(foreground,
          result);
Now  can u please tell me how to use these methods in java?or is there any alternative for this method?please help/suggest me?

Thanks In Advance
OriginalImage.jpg
Image.jpg
GrabCutImage.jpg

Samuel Audet

unread,
Feb 1, 2014, 7:06:12 PM2/1/14
to jav...@googlegroups.com
On 01/27/2014 03:25 PM, Prakash Parupudi wrote:
Here i have attached 3 images. originalImage.jpg is my image ,grabCutImage.jpg is my expected image and i was stuck near Image.jpg( pixels marked as likely foreground).

Now in order to get GrabCutImage.jpg from Image.jpg i need to use CvMatForeground which is used in c++ as below :

 cv::Mat foreground(image.size(),CV_8UC3,cv::Scalar(255,255,255)); 
image.copyTo(foreground,
          result);
Now  can u please tell me how to use these methods in java?or is there any alternative for this method?please help/suggest me?

That would be `cvCopy(image, result, foreground)`:
http://docs.opencv.org/modules/core/doc/old_basic_structures.html#copy

Samuel
Message has been deleted
Message has been deleted

Samuel Audet

unread,
Feb 3, 2014, 8:12:28 AM2/3/14
to jav...@googlegroups.com
On 02/02/2014 02:20 PM, Prakash Parupudi wrote:
> i am getting Binary image now.........so how to get coloured image from
> it? and can u please tell me java method for the following
>
>> |cv::Mat foreground(image.size(),CV_8UC3,cv::Scalar(255,255,255));|
>
> Thanks In Advance

Oops, I got that reversed. That would be:
IplImage foreground = IplImage.create(image.width(),
image.height(), IPL_DEPTH_8U, 3);
cvCopy(image, foreground, result);

Samuel
Message has been deleted

Prakash Parupudi

unread,
Feb 5, 2014, 12:13:51 AM2/5/14
to jav...@googlegroups.com
Thank You Samuel ....
Reply all
Reply to author
Forward
0 new messages