regcntsSubs.c
/* open and run the region filter, returning mask of valid segments */
open and run the region filter, returning mask of valid segments
open and run the region filter returning mask of valid segments
int regcntsOpenRegions(Data d){
  char *u, *t;
  d->reg = OpenRegions(d->cards, d->regstr, NULL);
  if( d->reg && (d->reg != NOREGIONS) ){
    d->nmask = FilterRegions(d->reg, d->x0, d->x1, d->y0, d->y1, d->block, 
			     &d->masks, &d->nreg);
    t = d->reg->regstr;
    d->filtstr = xcalloc(strlen(t)*3, sizeof(char));
    for(u=d->filtstr; *t; t++){
      *u++ = *t;
      if( *t == '\n' ){
	*u++ = '#';
	*u++ = ' ';
      }
    }
    d->filtstr = xrealloc(d->filtstr, strlen(d->filtstr)+1);
  }
  if( d->nreg ){
    d->cnts = (double *)xcalloc(d->nreg, sizeof(double));
    d->savecnts = (double *)xcalloc(d->nreg, sizeof(double));
    d->area = (int *)xcalloc(d->nreg, sizeof(int));
    d->savearea = (int *)xcalloc(d->nreg, sizeof(int));
  }
  return d->nreg;
}
int regcntsOpenRegions ( Data d ) { char * u , * t ; d -> reg = OpenRegions ( d -> cards , d -> regstr , NULL ) ; if ( d -> reg && ( d -> reg != NOREGIONS ) ) { d -> nmask = FilterRegions ( d -> reg , d -> x0 , d -> x1 , d -> y0 , d -> y1 , d -> block , & d -> masks , & d -> nreg ) ; t = d -> reg -> regstr ; d -> filtstr = xcalloc ( strlen ( t ) * 3 , sizeof ( char ) ) ; for ( u = d -> filtstr ; * t ; t ++ ) { * u ++ = * t ; if ( * t == ' \n ' ) { * u ++ = ' ' ; * u ++ = ' ' ; } } d -> filtstr = xrealloc ( d -> filtstr , strlen ( d -> filtstr ) + 1 ) ; } if ( d -> nreg ) { d -> cnts = ( double * ) xcalloc ( d -> nreg , sizeof ( double ) ) ; d -> savecnts = ( double * ) xcalloc ( d -> nreg , sizeof ( double ) ) ; d -> area = ( int * ) xcalloc ( d -> nreg , sizeof ( int ) ) ; d -> savearea = ( int * ) xcalloc ( d -> nreg , sizeof ( int ) ) ; } return d -> nreg ; }
open and run the region filter, returning mask of valid segments
open and run the region filter returning mask of valid segments
/* retrieve region mask segments */ /* for display, we have to add # comment chars after each \n */ /* allocate space for results */