一个奇怪的问题

      好久没来了!

     今天又碰到一个非常奇怪的问题!我现在先记录下来,看以后能不能解决吧!

    程序段一:

 for(i=mat->height-2;i>=0;i--)
  for(j=1;j<mat->width;j++)
   if(cvGetReal2D(mat,i,j)==0)
   {
    x=i;y=j;
    if((cvGetReal2D(mat,x,y-1)==1)&&(cvGetReal2D(mat,x+1,y)==1))
      cvSetReal2D(index,x,y,key++);
    if((cvGetReal2D(mat,x,y-1)==0)&&(cvGetReal2D(mat,x+1,y)==1))
      cvSetReal2D(index,x,y,cvGetReal2D(index,x,y-1));
    if((cvGetReal2D(mat,x,y-1)==1)&&(cvGetReal2D(mat,x+1,y)==0))
      cvSetReal2D(index,x,y,cvGetReal2D(index,x+1,y));
    if((cvGetReal2D(mat,x,y-1)==0)&&(cvGetReal2D(mat,x+1,y)==0))
cvSetReal2D(index,x,y,cvGetReal2D(index,x,y-1)<cvGetReal2D(index,x+1,y)?cvGetReal2D(index,x,y-1):cvGetReal2(index,x+1,y));
   }

程序段二:

for(i=mat->height-2;i>=0;i--)
  for(j=1;j<mat->width;j++)
   if(cvGetReal2D(mat,i,j)==0)
    {
      x=i;y=i;//这里写错了,应该是y=j;
     if((cvGetReal2D(mat,x,y-1)==1)&&(cvGetReal2D(mat,x+1,y)==1)) 
   cvSetReal2D(index,x,y,key++);
     if((cvGetReal2D(mat,x,y-1)==0)&&(cvGetReal2D(mat,x+1,y)==1)) 
   cvSetReal2D(index,x,y,cvGetReal2D(index,x,y-1));
     if((cvGetReal2D(mat,x,y-1)==1)&&(cvGetReal2D(mat,x+1,y)==0)) 
   cvSetReal2D(index,x,y,cvGetReal2D(index,x+1,y));
  if((cvGetReal2D(mat,x,y-1)==0)&&(cvGetReal2D(mat,x+1,y)==0))  
cvSetReal2D(index,x,y,cvGetReal2D(index,x,y-1)<cvGetReal2D(index,x+1,y)?cvGetReal2D(index,x,y-1):cvGetReal2(index,x+1,y));
    }

这两个程序是我在不同的时间写的,都是一样的,但是奇怪的是,程序一可以正常使用,程序二就报错!检查了一上午也没发现问题!

刚在排版这篇文章的时候发现了错误!原来也是粗心!记录下来吧,以后当警告!~

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值