Sliceproc Module

The sliceproc module contains functions for doing filtering on byte images in Islice structures, and for advanced operations such as median filtering, anisotropic diffusion, and edge tapering on slices of various modes.

Header to include: sliceproc.h
(includes mrcslice.h)


int sliceByteAdd(Islice *sin, int inVal)
int sliceByteEdgeTwo(Islice *sin, int center)
int sliceByteEdgeSobel(Islice *sin)
int sliceByteEdgePrewitt(Islice *sin)
int sliceMedianFilter(Islice *slOut, Istack *stack, int size)
int sliceAnisoDiff(Islice *sl, int outMode, int CC, double k, double lambda, int iterations, int clearFlag)
void sliceByteAnisoDiff(Islice *sl, float **image, float **image2, int CC, double k, double lambda, int iterations, int *iterDone)
float **allocate2D_float(int m, int n )

int sliceByteAdd(Islice *sin, int inVal)

Adds inVal to all values in the slice sin, which must contain bytes. Returns 0.

int sliceByteEdgeTwo(Islice *sin, int center)

Computes a Prewitt or Sobel edge filter on the slice sin, depending on whether the center pixel weighting, center, is 1 or 2.  The slice must contain bytes.  Returns 0.

int sliceByteEdgeSobel(Islice *sin)

Computes a Sobel edge filter on the slice sin, which must contain bytes.  Returns 0.

int sliceByteEdgePrewitt(Islice *sin)

Computes a Prewitt edge filter on the slice sin, which must contain bytes.  Returns 0.

int sliceMedianFilter(Islice *slOut, Istack *stack, int size)

Applies a 2-D or 3-D median filter to the slices contained in the Istack structure stack, with the size in X and Y specified by size and the size in Z determined by the number of slices in the stack.  Puts the output into slOut, which should already be set up for size and mode and have a data array, but need not have the same mode as the input slices. Input and output modes can be byte, short, or float.  Computation of a 2-D 3x3 filter on a float image into a float image is highly optimized as well as parallelized with OpenMP.  Parallelization was not effective for other cases.  Returns -1 for memory error or -2 for an illegal mode.

int sliceAnisoDiff(Islice *sl, int outMode, int CC, double k, double lambda, int iterations, int clearFlag)

Does anisotropic diffusion on slice sl using the Perona and Malik filtering method, based on a program by Alejandro Canterero. outMode specifies the output mode; CC is edge stopping type (1, 2, 3), k is the threshold parameter, lambda is the step size, iterations is the number of iterations to run.  clearFlag is one of ANISO_CLEAR_AT_END, ANISO_LEAVE_OPEN, or ANISO_CLEAR_ONLY to allow additional iterations to be done on the existing data.  Returns -1 for memory error.

void sliceByteAnisoDiff(Islice *sl, float **image, float **image2, int CC, double k, double lambda, int iterations, int *iterDone)

Does anisotropic diffusion on slice sl, which must contain bytes. image and image2 are float arrays of size xsize + 2 by ysize + 2 that have already been allocated with allocate2D_float. CC is edge stopping type (1, 2, 3), k is the threshold parameter, lambda is the step size, iterations is the number of iterations to run.  iterDone is maintained with the total number of iterations done.

float **allocate2D_float(int m, int n )

Allocates a  2D array of doubles of size m by n that is contiguous in memory.  The array is actually a 1D vector of length m x n, and this routine returns an array of pointers to the rows.