注册 登录
编程论坛 C++ Builder

C++ Builder 中画出火焰图像的边界问题

xiangqin6666 发布于 2013-10-31 15:14, 3619 次点击
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        if(OpenPictureDialog1->Execute())
        {
                Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
                width=Image1->Picture->Width;
                height=Image1->Picture->Height;
                //读入位图各象素点图像的RGB值
                int i,j;
                rgb=new RGBColor*[width];
                TColor color;
                for(i=0;i<width;i++)
                {
                        rgb[i]=new RGBColor[height];
                        for(j=0;j<height;j++)
                        {
                                color=Image1->Canvas->Pixels[i][j];
                                rgb[i][j].r=GetRValue(color);
                                rgb[i][j].g=GetGValue(color);
                                rgb[i][j].b=GetBValue(color);
                        }
                }
        }
}
void __fastcall TForm1::Button3Click(TObject *Sender)
{
      
        //边缘检测
      
        int *m,*p;

        int i,j,s,n=0;

        for(i=0;i<width;i++)
              {
               for(j=0;j<height;j++)
             {
              rgb[i][j].r=GetRValue(Image1->Canvas->Pixels[i][j]) ;

                       if(rgb[i][j].r<130)
                      G[i][j]=0;
                        else
                        G[i][j]=1;
                  }

                 for(i=0;i<width;i++)
                     {
                     for(j=0;j<height;j++)
                    {
   if((G[i-1][j]==0&&G[i][j]==1&&G[i+1][j+2]==1)&&(G[i-1][j-2]==1||G[i+1][j+2]==1)&&(G[i+1][j-2]==1||G[i-1][j+2]==1)&&(G[i][j-2]==1||G[i][j+2]==1) )这个是在另外一个程序上粘的  我也没看懂是什么意思,是不是这里出错了
     {
       m[n]=i;
       p[n]=j;
       n++;                           //记录边缘点像素坐标以及边缘点个数
      }
   }
 }
  Image3->Canvas->Pen->Color=clBlue;
  Image3->Canvas->Pen->Width=1;


 for(s=1;s<n;s++)
  {
     Image3->Canvas->MoveTo(m[s-1],p[s-1]);  //连接边缘点
     Image3->Canvas->LineTo(m[s],p[s]);

  }


}
}
想把一个火焰图像的边界的画出来   可是怎么都不对 求帮忙啊
1 回复
#2
yuccn2013-10-31 21:06
靠,那么搓的代码

看不懂你都拷贝过来?
估计只有作者知道什么意思,几天之后作者多不知道什么意思了
1