Exemplo n.º 1
0
bool gvVisionTask_black::gvTask_inspect( Hobject image_src, Hobject *outRegion_defects )
{
	// Local iconic variables
	Hobject  TMP_Region, Region1, RegionErosion1,ImageReduced;
	Hobject  Image_meanSmall, Image_meanLarge, RegionDynThresh;
	Hobject  ConnectedRegions, RegionFillUp, RegionErosion, ConnectedRegions1;
	Hobject  SelectedRegions, RegionDilation1, RegionDilation;
	Hobject  RegionDifference, obj_selected;


	// Local control variables
	HTuple  Meancenter, Deviation, Meanouter, Deviation1;
	HTuple  Index, Number;

//	reduce_domain(image_src, gvTask_GetROI()->gvROI_GetROI(), &ImageReduced);
	reduce_domain(image_src, gvTask_GetROI()->gvROI_GetROI(), &ImageReduced);
	threshold(ImageReduced, &Region1, 100, 255);
	fill_up(Region1, &Region1);
	erosion_circle(Region1, &RegionErosion1, 20);
	mean_image(ImageReduced, &Image_meanSmall, 2, 2);
	mean_image(ImageReduced, &Image_meanLarge, 20, 20);
	dyn_threshold(Image_meanSmall, Image_meanLarge, &RegionDynThresh, 5, "dark");
	connection(RegionDynThresh, &ConnectedRegions);
	fill_up(ConnectedRegions, &RegionFillUp);


	erosion_circle(RegionFillUp, &RegionErosion, 1.5);
	connection(RegionErosion, &ConnectedRegions1);

	select_shape(ConnectedRegions1, &SelectedRegions, "area", "and", m_minBlackSpotArea, 5000);
	dilation_circle(SelectedRegions, &RegionDilation1, 2.5);
	intensity(RegionDilation1, Image_meanSmall, &Meancenter, &Deviation);
	dilation_circle(SelectedRegions, &RegionDilation, 5);
	difference(RegionDilation, SelectedRegions, &RegionDifference);
	intensity(RegionDifference, Image_meanSmall, &Meanouter, &Deviation1);
	gen_empty_obj(&(*outRegion_defects));
	for (Index=0; Index<=(Meancenter.Num())-1; Index+=1)
	{
		select_obj(SelectedRegions, &obj_selected, Index+1);
		if (0 != ((HTuple(Meancenter[Index])-HTuple(Meanouter[Index]))<-30))
		{
		  concat_obj((*outRegion_defects), obj_selected, &(*outRegion_defects));

		}
	}
	count_obj((*outRegion_defects), &Number);
	if(Number>m_maxBlackSpotCnt||Number<m_minBlackSpotCnt )
	{
		return FALSE;
	}
	return TRUE;
}
Exemplo n.º 2
0
int detectpsf(float *pix, int npx, int npy, 
	      float iso, float npix,
	      int rad,
	      int ndiv,
	      float infcri, float supcri,
	      float crit1,
	      float crit2,
	      float pixignr,
	      objrec_t **psfob)
{
  objrec_t  *ob, ob0, *ob1, *q;	/* object record */
  int i, j, nobj, sobj;
  int yshift;

  if(*psfob!=NULL)
    {
      free_objrec_list(*psfob);
      *psfob=NULL;
    }
  
  nobj=0;
  j=1;
  ob1=&ob0;
  for(i=0;i<ndiv;i++)
    {
      yshift=npy/ndiv*i;

      nobj+=detect_simple(pix+npx*yshift,npx,npy/ndiv,iso,
			  npix,&ob);
      if (ob!=NULL)
	{
	  ob1->next=ob;
	  ob1=ob1->next;
	  while(ob1->next!=NULL) 
	    {
	      ob1->entnum=j++;
	      ob1->yc+=(float)yshift;
	      ob1->jpeak+=yshift;
	      ob1->ymin+=yshift;
	      ob1->ymax+=yshift;
	      ob1=ob1->next;
	    }
	}
    }
  ob=ob0.next;
  
  printf("detected objects = %d\n", nobj);
  
  if(nobj==0)
    {
      free_objrec_list(ob0.next);
      return -1;
    }
  
  /* Determination of the Star Image Center
     and Determination of the Star Peak
     and Star Selection for PSF Making 
     and pixignr check */
  
  for(q=ob; q != NULL; q=q->next) 
    { 
      /* crit test */
      if (q->peak<infcri || q->peak>supcri) continue;
      if (!pixignr_check(pix, npx, npy, &q, rad, pixignr)) continue;
      if(det_center(pix, npx, npy, &q))
	/* The order of the check should be this order */
	{
	  q->img=(float*)malloc((q->xmax-q->xmin+3)*(q->ymax-q->ymin+3)*
				sizeof(float));
	  imextra(pix,npx,npy,
		  q->xmin-1,q->ymin-1,q->xmax+1,q->ymax+1,
		  q->img);
	  q->q=ab_r(q->img,(q->xmax-q->xmin+3),(q->ymax-q->ymin+3),
		    iso);
	  mk_psfob(&q, psfob);	     
	}
    }	
  free_objrec_list(ob0.next);
  
  if((*psfob) == NULL)
    {
      printf("No star candidates found\n");
      return 0;
    }
  
  /* Select object roughly by Ipeak/Npix and axis ratio */
  sobj = select_obj( psfob, crit1, crit2, rad);
  printf("selected stars = %d\n",sobj);
  if( sobj ==0 ||  (*psfob) == NULL)
    {
      printf("No star candidates found\n");
      return 0;
    }
  return sobj;
}