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 sliceByteEdgeLaplacian(Islice *sin)
int sliceByteSharpen(Islice *sin)
int sliceByteSmooth(Islice *sin)
int sliceByteConvolve(Islice *sin, int mask[3][3])
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 sliceMinMax(Islice *s)
void sliceScaleAndFree(Islice *sout, Islice *sin)

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 sliceByteEdgeLaplacian(Islice *sin)

Computes a Laplacian edge filter on the slice sin, which must contain bytes.  The Laplacian kernel is a -4 surrounded by 1's.  Returns 0.

int sliceByteSharpen(Islice *sin)

Computes a Laplacian edge filter on the slice sin, which must contain bytes.  The sharpening kernel is a 9 surrounded by -1's.  Returns 0.

int sliceByteSmooth(Islice *sin)

Smooths the slice sin, which must contain bytes, by convolving with a 3x3 smoothing kernel.  Returns 0.

int sliceByteConvolve(Islice *sin, int mask[3][3])

Convolves the slice sin with the 3x3 kernel in mask.  The slice 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.

int sliceMinMax(Islice *s)

Finds the min and max of slice s as rapidly as possible for the four basic data modes, byte, float, and signed and unsigned short integer. Returns 1 for other modes.

void sliceScaleAndFree(Islice *sout, Islice *sin)

Determines min and max of slice sout, determines scaling to match them to the min and max values provided in the byte slice sin, scales data into sin and frees sout.  To prevent rescaling, set the min and max of sin to zero.