标题:[求助]怎样把vc++改成c?
取消只看楼主
hannah168
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-5-24
 问题点数:0 回复次数:0 
[求助]怎样把vc++改成c?

那位高手帮忙把下面这段程序(一些图像处理的算法)改成c的阿? 不胜感激!!

void CAaaDlg::CutDib(bool Isshow,bool base)
{
int col_l1[10],col_l2[10],col_r1[10],col_r2[10],left,right,top,bottom;

long nowhite,white;
int ww=m_Dib.m_pBIH->biWidth;
int hh=m_Dib.m_pBIH->biHeight;
int valve=120; //边界阀值

//左上
for ( int i=hh-13;i<hh-3;i++)
{
nowhite=0;white=0;
for( int j=3;j<ww*3;j++)
{
/*t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] <valve) &&
(m_Dib.m_pDibBits[t+1] <valve) &&
(m_Dib.m_pDibBits[t+2] <valve ))*/

if (xyGray(j,i) < valve)
{ nowhite++; white=0;}
else
white++;
if (white>10)
{ col_l2[hh-i-4]=3+nowhite; break;}
} //end of for(int j=....)
}//end of for( int i=...)

//左下
for ( i=3;i<13;i++)
{
nowhite=0;white=0;
for(int j=3;j<ww*3;j++)
{
/*t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] <valve) &&
(m_Dib.m_pDibBits[t+1] <valve) &&
(m_Dib.m_pDibBits[t+2] <valve ))*/

if (xyGray(j,i) < valve)
{ nowhite++; white=0;}
else
white++;
if (white>10)
{ col_l1[i-3]=3+nowhite; break;}
} //end of for(int j=....)
}//end of for( int i=...)


//右上
for ( i=hh-13;i<hh-3;i++)
{
nowhite=0;white=0;
for(int j=ww*3;j>0;j--)
{
/*t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] <valve) &&
(m_Dib.m_pDibBits[t+1] <valve) &&
(m_Dib.m_pDibBits[t+2] <valve ))*/

if (xyGray(j,i) < valve)
{ nowhite++; white=0;}
else
white++;
if (white>10)
{ col_r2[hh-i-4]=ww-nowhite; break;}
} //end of for(int j=....)
}//end of for( int i=...)

//右下
for ( i=3;i<13;i++)
{
nowhite=0;white=0;
for(int j=ww*3;j>0;j--)
{
/*t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] <valve) &&
(m_Dib.m_pDibBits[t+1] <valve) &&
(m_Dib.m_pDibBits[t+2] <valve ))*/

if (xyGray(j,i) < valve)
{ nowhite++; white=0;}
else
white++;
if (white>10)
{ col_r1[i-3]=ww-nowhite; break;}
} //end of for(int j=....)
}//end of for( int i=...)

//确定左右胸靶边界,此时是左取最中间值,右取最小值
int lmax=0, lmin=320;
for(i=0;i<10;i++)
{
if (col_l1[i] > lmax)
lmax = col_l1[i];
if (col_l2[i] > lmax)
lmax = col_l2[i];

if (col_l1[i] < lmin)
lmin = col_l1[i];
if (col_l2[i] < lmin)
lmin = col_l2[i];
}

left = (lmin + lmax)/2 + 5;

right = 640;
for(i=0;i<10;i++)
{
if (col_r1[i] < right)
right=col_r1[i];
if (col_r2[i] < right)
right=col_r2[i];
}
right =right + 6;
//截去胸靶下部
nowhite=0;white=0;
for ( i=3;i<hh;i++)
{
int j=( left + right )/2;
/*t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] >190) &&
(m_Dib.m_pDibBits[t+1] >190) &&
(m_Dib.m_pDibBits[t+2] >190))*/

if (xyGray(j,i) > 190)
nowhite=0;
else
nowhite++;
if (nowhite>8)
{ bottom=i-11; break;}
}//end of for( int i=...)


//截去胸靶上部
nowhite=0;white=0;
for ( i= hh-3;i>0;i--)
{
int j=( left + right )/2;
/* t=i* ww *3 + j*3;
if ((m_Dib.m_pDibBits[t] >190) &&
(m_Dib.m_pDibBits[t+1] >190) &&
(m_Dib.m_pDibBits[t+2] >190))*/

if (xyGray(j,i) > 190)
nowhite=0;
else
nowhite++;
if (nowhite>8)
{ top=i+11; break;}
}//end of for( int i=...)


//根据上、下、左、右就可以初步确定圆心 center
if (base)
{
center[0]=(left+right)/2;
center[1]=(top+bottom)/2-35;

FindCenter(center[0],center[1]);

}
//截取胸环靶
int xhb_ww=right-left;
int xhb_hh=top-bottom;
OnClose();
if (xhb_ww <=200 || xhb_hh <= 200)
{
AfxMessageBox("请检查投影机和摄像机的位置!");
OnCancel();
}
//向全局变量传送边界值
border[0]=top;
border[1]=bottom;
border[2]=left;
border[3]=right;

//显示胸环靶
CWnd *pWnd=GetDlgItem(IDC_video);
CDC *pDC=pWnd->GetDC();
pWnd->Invalidate();
pWnd->UpdateWindow();
CPaintDC dc(this);
StretchDIBits( pDC->m_hDC, 0, 0,

xhb_ww, xhb_hh+2,

left,bottom,

xhb_ww, xhb_hh,

m_Dib.m_pDibBits,

(BITMAPINFO *) m_Dib.m_pBIH,

BI_RGB, SRCCOPY );
}

搜索更多相关主题的帖子: 不胜感激 bottom white 
2007-05-24 10:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-142075-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.350829 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved