示例#1
0
       //---------------------------------------------------------------------------------------------
       //returns the attention point with the maximum response in the given source image
       //---------------------------------------------------------------------------------------------
       public int getMaxAttentionPoint(classimage source_img, int search_radius)
       {
           int i,x,y,c,winner,cx=0,cy=0,mx,my;
           long max,pixels,p;

           max=0;
           winner=-1;
           for (i=0;i<NoOfAttentionPoints;i++)
           {
	           mx = attentionPoint[i,0];
               my = attentionPoint[i,1];

	           source_img.CG(mx-search_radius,my-search_radius,mx+search_radius,my+search_radius,0,0,0,ref cx,ref cy,0);

	           attentionPoint[i,0] = cx;
               attentionPoint[i,1] = cy;

	           p=0;
	           pixels=1;
    
	           for (x=cx-search_radius;x<cx+search_radius;x++)
	           {
	               if ((x>=0) && (x<width))
	               {
	                   for (y=cy-search_radius;y<cy+search_radius;y++)
		               {
	                       if ((y>=0) && (y<height))
		                   {
			                   for (c=0;c<3;c++) p += source_img.image[x,y,c];
		                   }
		                   pixels++;
		               }
	               }
	           }

	           if (p>max)
	           {
	               max = p;
	               winner=i;
	           }
           }

           attentionWinner=winner;
           return(winner);
       }
示例#2
0
       //---------------------------------------------------------------------------------------------
       //find maximal gravity wells in the image
       //---------------------------------------------------------------------------------------------
       public void findGravityWells(classimage source_img, int search_radius)
       {
           int x,y,c,border,cx=0,cy=0,tx,ty,bx,by,inhibit_radius;
           //bool found;

           border = search_radius/2;
           inhibit_radius = border/2;

           for (x=0;x<width;x++)
               for (y=0;y<height;y++)
	               for (c=0;c<3;c++)
	                   image[x,y,c]=0;

           for (x=0;x<width;x++)
               for (y=0;y<height;y++)
	           {
	               tx = x-border;
	               ty = y-border;
	               bx = x+border;
	               by = y+border;
 
	               source_img.CG(tx,ty,bx,by,0,0,0,ref cx,ref cy,0);
	               if (!((cx==0) && (cy==0)))
		           {
		               //are there any pixels within the inhibition region?
		               //found=false;

                       if ((cx>tx+inhibit_radius) && (cx<bx-inhibit_radius))
		               {
                           if ((cy>ty+inhibit_radius) && (cy<by-inhibit_radius))
			               {
                               for (c=0;c<3;c++) image[cx,cy,c]=255;
			               }
		               }
		           }
	           }
       }