/******************************************************************** * Dip.h - header file of the Image processing library * * Author: Hairong Qi, hqi@utk.edu, ECE, University of Tennessee * * Created: 01/22/06 * * Modification: ********************************************************************/ #ifndef DIP_H #define DIP_H #include "Image.h" #define PI 3.1415926 // flag for lowpass or highpass filter #define HIGH 1 #define LOW 0 ////////////////////////////////////////////// // point-based image enhancement processing Image negative(Image &); // image negative Image cs(Image &, // contrast stretching float, // slope float); // intercept Image logtran(Image &); // dynamic range compression Image powerlaw(Image &, // power-law transformation float); // the gamma value Image threshold(Image &, // thresholding an image float, // the threshold int nt=BINARY); // binary or grey-level thresholding // use "BINARY" or "GRAY" Image threshold(Image &, // thresholding an image float, // the lower threshold float, // the upper threshold int nt=BINARY); // binary or grey-level thresholding // use "BINARY" or "GRAY" Image autoThreshold(Image &); // use Otsu's automatic thresholding void bitplane(Image &, Image []); // bitplane slicing Image sampling(Image &, // downsample the image int); // the sampling ratio, should be > 1 Image quantization(Image &, // quantize the image int); // number of quantization levels Image histeq(Image &); // histogram equalization // add various types of noise to the image Image gaussianNoise(Image &inimg, // add Gaussian noise float std, // standard deviation of Gaussian float mean=0.0); // mean of Gaussian, default is zero Image sapNoise(Image &, // add salt and pepper noise float); // probability ///////////////////////////////////// // neighbor-based processing Image conv(Image &, // convolution between an image Image &); // and a mask image (kernel operation) // low-pass filters Image average(Image &, // average lowpass filter int size=3); // masksize (assume square mask) Image gaussianSmooth(Image &); // Gaussian lowpass filter Image median(Image &, // median filter int size=3); // masksize (assume square mask) Image gmean(Image &, // geometric mean int size=3); // masksize (assume square mask) Image amedian(Image &, // adaptive median filter int size=7); // maximum mask size Image contrah(Image &, // contraharmonic filter float, // the order of the filter int size=3); // the size (radius) of neighborhood // edge detectors Image roberts(Image &); // Roberts edge detector Image sobel(Image &); // Sobel edge detector void sobel(Image &img, // Sobel edge detector Image &mag, // edge magnitude Image &gradient); // edge direction Image prewitt(Image &); // Prewitt edge detector Image laplacian(Image &, // Laplacian edge detector int nt = 1); // use different types of kernel // 1 - [0 1 0; 1 -4 1; 0 1 0] // 2 - [1 1 1; 1 -8 1; 1 1 1] // 3 - [-1 2 -1; 2 -4 2; -1 2 -1] Image zeroCrossing(Image &); // find zero crossings in the image // frequency-domain filters Image ideal(Image &inimg, // the ideal filter int flag, // HIGH for highpass, LOW for lowpass float radius); Image butterworth(Image &inimg, // the butterworth filter int flag, // HIGH for highpass, LOW for lowpass float radius, int n); // controls the sharpness of the curve Image gaussianFreq(Image &inimg, // the Gaussian filter int flag, // HIGH for highpass, LOW for lowpass float std); // standard deviation Image inverseFilter(Image &inimg, // the inverse filter float std); // standard deviation of the blur kernel Image wiener(Image &inimg, // the input image float K, // power of noise / power of signal float std); // standard deviation of the blur kernel // assuming it's Gaussian //////////////////////////////////// // geometric transformations Image translate(Image &, // translation float, float); // tx and ty Image shear(Image &, // shear float, float); // hx and hy Image scale(Image &, // scale float, float); // sx and sy Image rotate(Image &, // rotation float); // angle in degree (counterclock is +) Image perspective(Image &, // perspective transform Image &); // coordinates of n tiepoints // an nx4 matrix with the first two cols // coordinates from the original image // and the last two cols those of the // transformed image //////////////////////////////////// // Fourier transform void fft(Image &inimg, // forward transform Image &mag, Image &phase); void ifft(Image &outimg, // inverse transform Image &mag, Image &phase); void fftifft(Image &inimg, // FFT Image &mag, Image &phase, int scale); // 1: forward trans; -1: inverse trans //////////////////////////////////// // color processing routines Image RGB2HSI(Image &); // convert from RGB to HSI model Image HSI2RGB(Image &); // convert from HSI to RGB model //////////////////////////////////// // other utility functions float psnr(Image &, // peak SNR, original image Image &); // degraded image float rmse(Image &, // root mean square error, original image Image &); // degraded image double gaussrand(); // generate a Gaussian random # (-3,3) void bubblesort(float *, // bubblesort, pointer to the array int); // size of the array void bubblesort(float *, // bubblesort, pointer to the array int, // size of the array int *p); // pointer to the index float power(Image &); // return the power of an image Image sqrt(Image &); // function overloading of sqrt() // pixel-wise processing Image abs(Image &); // overloading function abs(), pixel-wise float norm(float, float); // calculate magnitude float sum(Image &img); // summation of all pixel intensities void outofMemory(); // print error message int floorPower2(int); // the largested power of 2 <= the given #endif