16,004,727 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by mohamed sabri (Top 4 by date)
mohamed sabri
31-Oct-14 12:16pm
View
i don't understant plz more
mohamed sabri
9-Sep-14 9:39am
View
Collapse | Copy Code
void Foreground_SCGMM_movcam::graphcut_fg_decission(ImageRGB & in, ImageGray & out,
Mat_2D_float64 & Prob_fg, Mat_2D_float64 & Prob_bg, float64 lambda)
{
uint64 WIDTH = in.cols;
uint64 HEIGHT = in.rows;
Graph::node_id *pnodes = new Graph::node_id[WIDTH*HEIGHT];
Graph *g = new Graph();
uint64 x,y;
Graph::node_id var;
Graph::node_id qvar;
Graph::captype E0,E1;
uint64 iPixel = 0;
uint64 qPixel =0;
array<int32,2> p,q;
uint64 k;
uint8 pR;
uint8 pG;
uint8 pB;
float64 var_intensity=0;
float64 distance_pq=0;
float64 expon, V_pq;
uint8 qR, qG, qB;
for(y=0;y< HEIGHT;y++)
{
for(x=0;x<width;x++)>
{
p[0] = x;
p[1] = y;
pR=in.data[in.step*(y) + in.channels()* (x) + 2];
pG=in.data[in.step*(y) + in.channels()* (x) + 1];
pB=in.data[in.step*(y) + in.channels()* (x) + 0];
for (k=0; k<neighbor_num;>
{
q[0] = p[0] + NEIGHBORS[k][0];
q[1] = p[1] + NEIGHBORS[k][1];
if ((q[0] >= 0) && (q[1] >=0) && (q[0] < (int64)WIDTH)
&& (q[1] < (int64)HEIGHT) )
{
qR=in.data[in.step*(q[1]) + in.channels()* (q[0]) + 2];
qG=in.data[in.step*(q[1]) + in.channels()* (q[0]) + 1];
qB=in.data[in.step*(q[1]) + in.channels()* (q[0]) + 0];
distance_pq=(pR-qR)*(pR-qR) + (pG-qG)*(pG-qG) + (pB-qB)*(pB-qB);
}
}
var_intensity += distance_pq/NEIGHBOR_NUM;
}
}
var_intensity= var_intensity/(HEIGHT*WIDTH);
printf("\n var_intensity:%E \n", var_intensity);
distance_pq=0;
for(y=0;y< HEIGHT;y++)
for(x=0;x<width;x++)>
{
pnodes[iPixel]= g -> add_node();
iPixel++;
}
iPixel =0;
for(y=0;y<height;y++)>
{
float64* ptr_Prob_bg = (float64*)Prob_bg.data + Prob_bg.cols*uint32(y);
float64* ptr_Prob_fg = (float64*)Prob_fg.data + Prob_fg.cols*uint32(y);
for(x=0;x<width;x++)>
{
p[0] = x;
p[1] = y;
pR=in.data[in.step*(y) + in.channels()* (x) + 2];
pG=in.data[in.step*(y) + in.channels()* (x) + 1];
pB=in.data[in.step*(y) + in.channels()* (x) + 0];
var = pnodes[iPixel];
if(pR == 0) // IF PIXEL IS BACKGROUND /// NO IF si probabilitats
{
E0=0;
E1=1;
}
else
{
E0=1;
E1=0;
}
E0 = (-1)* log(ptr_Prob_bg[Prob_bg.channels()*x]);
E1 = (-1)* log(ptr_Prob_fg[Prob_fg.channels()*x]);
g->add_tweights(var,E0,E1);
if(_lambda != 0.0){
for (k=0; k<neighbor_num;> {
// q = p + NEIGHBORS[k];
q[0] = p[0]+ NEIGHBORS[k][0];
q[1] = p[1] + NEIGHBORS[k][1];
if ((q[0] >= 0) && (q[1] >=0) && (q[0] < (int64)WIDTH)
&& (q[1] < (int64)HEIGHT) )
{
qPixel = q[0] + (q[1]*WIDTH);
qvar = pnodes[qPixel];
// Calcular V(p,q)
qR=in.data[in.step*(q[1]) + in.channels()* (q[0]) + 2];
qG=in.data[in.step*(q[
mohamed sabri
9-Sep-14 9:33am
View
OK I reply this code without commented lines
mohamed sabri
9-Sep-14 9:08am
View
what's the problem exactly?
is it to erase there commented lines