www.pudn.com > imgproc.zip > ROUTINES.H


// **************************************************************** 
//  Image process tool box 
//     by Yang Yudong 
// 
// File : routines.h 
// Description:  image processing general routines header file 
// Create Date:  1996. 9. 11 
// Modification(date/where):   1996. 10.01 reformatted as standard 
// Modification(date/where):   1996. 12.10 add fast routines 
// Modification(date/where):   1997.  1.13 add clip routines 
// Modification(date/where):   1997.  5.14 add fastrtns.c routines 
// **************************************************************** 
 
#ifndef _INC_ROUTINES 
 
// cliprect.c 
BOOL __clip_rect(int src_xsz, int src_ysz, int des_xsz, int des_ysz,  
                 int *xsts, int *ysts, int *xstd, int *ystd, int *xblk, int *yblk); 
 
// convfilt.c 
void store_addr3x3(int addr[9], int xsize); 
void store_addr5x5(int addr[25], int xsize); 
void convolution3x3(BYTE *src, short int *des, short int mtx[9], int xsize, int ysize); 
void self_convolution3x3(BYTE  *src, short int mtx[9], short int divisor, int xsize, int ysize); 
void blank_frame(void *buf, int xsize, int ysize, int elmsz); 
void trace_peak(BYTE *img, short int *buf, int xsize, int ysize, int th); 
 
// fastconv.c 
void sobel_edge(BYTE *img, short int *buf, int xsize, int ysize); 
void sobel_edge_unsigned(BYTE *img, int xsize, int ysize); 
void find_edge_fast(BYTE *img, short int *buf, int xsize, int ysize); 
void blur_3x3(BYTE  *img, int xsize, int ysize); 
void blur_3x3_fast(BYTE  *img, short int *buf, int xsize, int ysize); 
 
// colorpre.c 
void color_unify(BYTE *cr, BYTE *cg, BYTE *cb, int xsize, int ysize); 
short diffcolor(BYTE r1, BYTE g1, BYTE b1, BYTE r2, BYTE g2, BYTE b2); 
 
// imghisto.c 
int select_threshold(int *histo, int hsize, int scale1000); 
void count_histo(int *histo, int hsize, void *ptr, int sz, int cnt); 
 
// looktbl.c 
void table_mod_(BYTE *tabaddr, BYTE *buffer, int imgWidth, int imgHeight); 
void threshold_(BYTE *buffer, BYTE th, BYTE small, BYTE big, int imgWidth, int imgHeight); 
 
// lut2d.c 
void __lut2d(BYTE *src, int srcx, int srcy, BYTE *des, int desx, int desy, long *lutxy, BYTE fills); 
void __lut2d_fast(BYTE *src, int srcx, int srcy, BYTE *des, int desx, int desy, long *lutxy, BYTE fills); 
void __lut2d_fine(BYTE *src, int srcx, int srcy, BYTE *des, int desx, int desy, long *lutxy, BYTE fills); 
 
 
// resample.c 
void __resample(BYTE *src, int imgWidth, int imgHeight, BYTE *des, int newWidth, int newHeight); 
void __resample_fast(BYTE *src, int imgWidth, int imgHeight, BYTE *des, int newWidth, int newHeight); 
void __resample_fine(BYTE *src, int imgWidth, int imgHeight, BYTE *des, int newWidth, int newHeight); 
 
// imedian.c 
BOOL __image_median(BYTE *src, BYTE *des, int xsize, int ysize, int size2); 
 
// imajor.c  
// do majority filter of (size2*2+1)*(size2*2+1) of src to get des 
BOOL __image_majority(BYTE *src, BYTE *des, int xsize, int ysize, int size2); 
 
// ishrink.c 
void __shrink_expand(BYTE *bf, int xsz, int ysz, BOOL expd, BOOL conn4); 
 
 
#define swapit(a, b, type) {type __swap; __swap = (a); (a) = (b); (b) = __swap}; 
 
#ifdef __WATCOMC__ 
  //$$$ This is machine dependent 
  //$$$ it is for Watcom C32 10.0 on Intel i386 platform 
  extern short int limit_it(short int a); 
  #pragma aux limit_it=\ 
		"cmp    ax, 0"  \ 
		"jge    no_neg" \ 
		"neg    ax"     \ 
  "no_neg: 	 cmp    ax, 255"\ 
		"jle    no_over"\ 
		"mov    ax, 255"\ 
  "no_over:"                      \ 
		parm [ax]       \ 
		value[ax] 
  extern short int myabs(short int a); 
  #pragma aux myabs=\ 
		"cmp    ax, 0"  \ 
		"jge    no_neg" \ 
		"neg    ax"     \ 
  "no_neg:"	                \ 
		parm [ax]       \ 
		value[ax] 
 
  extern int trunc_8(int a); 
  #pragma aux trunc_8=\ 
		"cmp    eax, 0"  \ 
		"jge    no_neg" \ 
		"xor    eax,eax"     \ 
  "no_neg: 	 cmp    eax, 255"\ 
		"jle    no_over"\ 
		"mov    eax, 255"\ 
  "no_over:"                      \ 
		parm [eax]       \ 
		value[eax] 
 
#else 
  #ifdef _MSC_VER 
  //MSC writing 
    __inline short int limit_it(short int a) { 
      if(a < 0)  
         if( a < -255) return 255; else return -a; 
      else if(a > 255) return 255; 
      else return a; 
    } 
    __inline short int myabs(short int a) {if(a<0) return -a; else return a;} 
    __inline int trunc_8(int a) { 
      if(a < 0) return 0; 
      else if(a > 255) return 255; 
      else return a; 
    } 
  #else 
  // if inline is not supported then this is defined in: fastrtns.c 
    short int m_limit_it(short int a); 
    short int m_myabs(short int a); 
    int m_trunc_8(int a); 
    #define  limit_it(a)  m_limit_it(a) 
    #define  myabs(a)     m_myabs(a) 
    #define  trunc_8(a)   m_trunc_8(a) 
  #endif 
#endif 
 
#define _INC_ROUTINES 
#endif