Tapering and Padding Images

The functions listed here are defined in taperpad.c and taperatfill.c. They are declared in cfsemshare.h, which includes mrcslice.h and is included by b3dutil.h.

Functions for Tapering and Padding Images


void sliceTaperOutPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int ifmean, float dmeanin)
void taperoutpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *ifmean, float *dmeanin)
void sliceTaperInPad(void *inArray, int type, int nxDimIn, int ixStart, int ixEnd, int iyStart, int iyEnd, float *outArray, int nxDimOut, int nx, int ny, int nxTaper, int nyTaper)
void taperinpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *nxtap, int *nytap)
void taperinpadex(void *array, int *nxdimin, int *ix0, int *ix1, int *iy0, int *iy1, float *brray, int *nxdim, int *nx, int *ny, int *nxtap, int *nytap)
void sliceSmoothOutPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny)
void smoothoutpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny)
void sliceNoiseTaperPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int noiseLength, int noiseRows, float *temp)
void slicenoisetaperpad(float *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *noiseLength, int *noiseRows, float *temp)
double sliceEdgeMean(float *array, int nxdim, int ixlo, int ixhi, int iylo, int iyhi)
double sliceedgemean(float *array, int *nxdim, int *ixlo, int *ixhi, int *iylo, int *iyhi)
void sliceSplitFill(float *array, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int iffill, float fillin)
void splitfill(float *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *iffill, float *fillin)

Functions for Tapering an Image at Fill Areas


int sliceTaperAtFill(Islice *sl, int ntaper, int inside)
int taperatfill(float *array, int *nx, int *ny, int *ntaper, int *inside)
int getLastTaperFillValue(float *value)
int getlasttaperfillvalue(float *value)

Functions for Tapering and Padding Images

void sliceTaperOutPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int ifmean, float dmeanin)

Pads an image in array with dimensions nxbox by nybox into the center of a larger array, brray, which can be the same as array.  The SLICE_MODE is specified by type, which must be byte, float or short integer. The size of the padded image is specified by nx and ny while nxdim specifies the X dimension of the output array.  The values of the image in the padding area will be tapered from the value of a pixel at the edge of the input image edge down to a common value.  That value is either the mean at the edge of the input image, if ifmean is zero, or the value supplied in dmeanin, if ifmean is nonzero.  The offset to the original data in the padded array is (nx - nxbox) / 2, (ny - nybox) / 2.

void taperoutpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *ifmean, float *dmeanin)

Fortran wrapper to call sliceTaperOutPad with a floating point array.

void sliceTaperInPad(void *inArray, int type, int nxDimIn, int ixStart, int ixEnd, int iyStart, int iyEnd, float *outArray, int nxDimOut, int nx, int ny, int nxTaper, int nyTaper)

Extracts a subarea of an image, places it into the center of a potentially larger array with padding, and tapers the image down to the mean value at its edge, tapering pixels inside the extracted image area.  The image data are in inArray, their X dimension is nxDimIn, and their SLICE_MODE is given in type.  The mode can be byte, signed or unsigned short, float, or RGB.  The starting and ending coordinates to extract in X and Y are ixStart to ixEnd and iyStart to iyEnd.  The output image array is outArray and its X dimension is specified by nxDimOut.  The padded image size is specified by nx and ny, and nxTaper and nyTaper indicate the number of pixels over which to taper in X and Y.  The output array can be the same as the input array if the input image fills the entire array.  The offset to the original image in the padded array is nx / 2 - (ixEnd + 1 - ixStart) / 2, ny / 2 - (iyEnd + 1 - iyStart) / 2.

void taperinpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *nxtap, int *nytap)

Fortran wrapper to sliceTaperInPad for padding a whole float image array of size nxbox by nybox.  The output array can be the same as the input array.

void taperinpadex(void *array, int *nxdimin, int *ix0, int *ix1, int *iy0, int *iy1, float *brray, int *nxdim, int *nx, int *ny, int *nxtap, int *nytap)

Fortran wrapper to sliceTaperInPad for padding a subarea from a float image array

void sliceSmoothOutPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny)

Pads an image in array with dimensions nxbox by nybox into the center of a larger array, brray, which can be the same as array.  The SLICE_MODE is specified by type, which must be byte, float or short integer. The size of the padded image is specified by nx and ny while nxdim specifies the X dimension of the output array.  The padding is done by replicating pixels and smoothing lines progressively more for farther out from the pixels in the box.  This is done in a series of progressively larger rectangles; the each pixel in first rectangle contains the average of the three nearest pixels on the outer edge of the actual data; each pixel in the second rectangle is the average of the 5 nearest pixels in the first rectangle, etc.  The offset to the original data in the padded array is (nx - nxbox) / 2, (ny - nybox) / 2.

void smoothoutpad(void *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny)

Fortran wrapper to call sliceSmoothOutPad with a floating point array.

void sliceNoiseTaperPad(void *array, int type, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int noiseLength, int noiseRows, float *temp)

Pads an image in array with dimensions nxbox by nybox into the center of a larger array, brray, which can be the same as array.  The SLICE_MODE is specified by type, which must be byte, float or short integer. The size of the padded image is specified by nx and ny while nxdim specifies the X dimension of the output array.  The values of the image in the padding area will be drawn randomly from an elongated box adjacent to the image edge and attenuated down to the mean of the input image edge at the edge of the output image.  The width of the box is supplied in noiseRows; the length of the box is supplied in noiseLength and is limited to 600 divided by the width. The box is centered on the pixel at the edge nearest to a pixel that is being filled. An array must supplied in temp that is at least 2 times the maximum of nxBox and nyBox plus nx - nxbox plus ny - nybox.  The offset to the original data in the padded array is (nx - nxbox) / 2, (ny - nybox) / 2.

void slicenoisetaperpad(float *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *noiseLength, int *noiseRows, float *temp)

Fortran wrapper to call sliceNoiseTaperPad with a floating point array

double sliceEdgeMean(float *array, int nxdim, int ixlo, int ixhi, int iylo, int iyhi)

Computes the mean along the edge for the portion of the image in array bounded by X indices ixlo and ixhi and Y indices iylo and iyhi, inclusive.  nxdim is the X dimension of the array.  The mean is based solely on the single columns at ixlo and ixhi and the single rows at iylo and iyhi.

double sliceedgemean(float *array, int *nxdim, int *ixlo, int *ixhi, int *iylo, int *iyhi)

Fortran wrapper to sliceEdgeMean .  The indexes are numbered from 1.

void sliceSplitFill(float *array, int nxbox, int nybox, float *brray, int nxdim, int nx, int ny, int iffill, float fillin)

Splits a small image in array with dimensions nxbox by nybox into the 4 corners of a potentially larger array.  The padded image is placed in brray with a size of nx by ny, where nxdim is the X dimension of brray.  The image will be padded with the mean at the edge of the image, or with the value in fillin if iffill is non-zero.  In either case the values will be shifted so that the mean of the whole array is zero.

void splitfill(float *array, int *nxbox, int *nybox, float *brray, int *nxdim, int *nx, int *ny, int *iffill, float *fillin)

Fortran wrapper to sliceSplitFill .

Functions for Tapering an Image at Fill Areas

int sliceTaperAtFill(Islice *sl, int ntaper, int inside)

Analyzes for fill areas at the edge of the slice sl, finds the borders between actual image and fill areas, and tapers the image intensities down to the fill value over ntaper pixels.  If inside is 0 the image intensities at the edge are extended into the fill area, while if inside is 1 then pixels inside the image are attenuated.  Returns -1 for memory allocation errors.

int taperatfill(float *array, int *nx, int *ny, int *ntaper, int *inside)

Fortran wrapper to sliceTaperAtFill for tapering a real*4 image in array of size nx by ny.  Returns -1 for memory error.

int getLastTaperFillValue(float *value)

Returns the fill value found on last call in value and a return value of 1 if a value was found, or 0 if not.

int getlasttaperfillvalue(float *value)

Fortran wrapper to getLastTaperFillValue