Page 1 of 1

KernelInfo updating

Posted: 2015-02-09T17:33:18-07:00
by Danack
Hi,

When a KernelInfo struct has been created, and the values in the kernel are then modified, is it required that the values of

minimum, maximum, negative_range, positive_range, angle;

in the struct are updated by whoever modified the kernel or are they updated elsewhere?

Also, I can guess what minimum and maximum are; are the entries negative_range, positive_range, and angle described anywhere as to what they are meant to be?

cheers
Dan

Re: KernelInfo updating

Posted: 2015-02-09T18:04:45-07:00
by snibgo
I haven't done much programming with kernels, but it looks to me that if you want to create or modify your own, you should do the same work as morphology.c function ParseKernelArray() or CalcKernelMetaData().

Re: KernelInfo updating

Posted: 2015-02-09T18:32:38-07:00
by Danack
Thanks, the CalcKernelMetaData looks like the right one to copy.

After looking at it, it seems that the angle value is only used for rotating the kernels. So as long as I don't want to use those, it should just be left to 0?

Re: KernelInfo updating

Posted: 2015-02-09T18:40:46-07:00
by snibgo
I can't be certain (your guess is probably better than mine), but when modifying a kernel, I think you should not change angle.

Re: KernelInfo updating

Posted: 2015-02-10T12:51:20-07:00
by Danack
btw it would be good if the code below from morphology.c was moved to it's own function where it could be reused. I think it's needed by anyone that wants to allow users to specify a string to create a Kernel.

Or possibly just the whole ParseKernelName() function.

Some documentations of how the values of GeometryInfo are used would also be awesome because:

double
rho,
sigma,
xi,
psi,
chi;

Just aren't that self-documenting.

Code: Select all


  /* special handling of missing values in input string */
  switch( type ) {
    /* Shape Kernel Defaults */
    case UnityKernel:
      if ( (flags & WidthValue) == 0 )
        args.rho = 1.0;    /* Default scale = 1.0, zero is valid */
      break;
    case SquareKernel:
    case DiamondKernel:
    case OctagonKernel:
    case DiskKernel:
    case PlusKernel:
    case CrossKernel:
      if ( (flags & HeightValue) == 0 )
        args.sigma = 1.0;    /* Default scale = 1.0, zero is valid */
      break;
    case RingKernel:
      if ( (flags & XValue) == 0 )
        args.xi = 1.0;       /* Default scale = 1.0, zero is valid */
      break;
    case RectangleKernel:    /* Rectangle - set size defaults */
      if ( (flags & WidthValue) == 0 ) /* if no width then */
        args.rho = args.sigma;         /* then  width = height */
      if ( args.rho < 1.0 )            /* if width too small */
          args.rho = 3;                /* then  width = 3 */
      if ( args.sigma < 1.0 )          /* if height too small */
        args.sigma = args.rho;         /* then  height = width */
      if ( (flags & XValue) == 0 )     /* center offset if not defined */
        args.xi = (double)(((ssize_t)args.rho-1)/2);
      if ( (flags & YValue) == 0 )
        args.psi = (double)(((ssize_t)args.sigma-1)/2);
      break;
    /* Distance Kernel Defaults */
    case ChebyshevKernel:
    case ManhattanKernel:
    case OctagonalKernel:
    case EuclideanKernel:
      if ( (flags & HeightValue) == 0 )           /* no distance scale */
        args.sigma = 100.0;                       /* default distance scaling */
      else if ( (flags & AspectValue ) != 0 )     /* '!' flag */
        args.sigma = QuantumRange/(args.sigma+1); /* maximum pixel distance */
      else if ( (flags & PercentValue ) != 0 )    /* '%' flag */
        args.sigma *= QuantumRange/100.0;         /* percentage of color range */
      break;
    default:
      break;
  }