00001 #include "sadie_byte.h" 00002 #include "mosaic.h" 00003 00004 00005 /*----------------------------------------------------------------------------*/ 00006 /*-General Information--------------------------------------------------------*/ 00007 /* */ 00008 /* Macro definitions for chain codes. */ 00009 /* */ 00010 /* */ 00011 /*----------------------------------------------------------------------------*/ 00012 #define NORMAL 0 00013 #define ADDED 1 00014 #define REMOVED 2 00015 00016 #define TERM_CODE 9 00017 #define TERM_VALID 0 00018 #define CHAIN_HEADER_SIZE 512 00019 00020 00021 /*----------------------------------------------------------------------------*/ 00022 /*-General Information--------------------------------------------------------*/ 00023 /* */ 00024 /* Data structures to store chain codes. */ 00025 /* */ 00026 /* */ 00027 /*----------------------------------------------------------------------------*/ 00028 typedef struct chain_node { 00029 unsigned char code; /* Code indicating orientation of current 00030 pixel wrt previous pixel in the chain. */ 00031 unsigned char valid; /* Tag indicating pixel validity. */ 00032 struct chain_code *next; /* Pointer to next pixel node. */ 00033 } CHAIN_NODE; 00034 00035 00036 typedef struct list_node { 00037 unsigned int startj; /* Line coordinate of first ring pixel. */ 00038 unsigned int startk; /* Pixel coordinate of first ring pixel. */ 00039 unsigned char ring_type; /* Number representing boundary type. */ 00040 int ring_id; /* Boundary ID. */ 00041 CHAIN_NODE *chain; /* Pointer to chain code of the ring. */ 00042 struct list_node *next; /* Pointer to chain code of next ring. */ 00043 } LIST_NODE; 00044 00045 00046 typedef struct { 00047 unsigned int nlin; /* Number of lines in image. */ 00048 unsigned int npix; /* Number of pixels/line. */ 00049 char header[504]; /* Header space for future expansion. */ 00050 LIST_NODE *list; /* Pointer to the list of chains. */ 00051 } CHAIN; 00052 00053 00054 /*----------------------------------------------------------------------------*/ 00055 /*-General Information--------------------------------------------------------*/ 00056 /* */ 00057 /* Function declarations. */ 00058 /* */ 00059 /* */ 00060 /*----------------------------------------------------------------------------*/ 00061 void RELMEM_CHAIN (CHAIN *); 00062 void CHAIN2DISK (CHAIN *,char *); 00063 void SCALE_CHAIN (CHAIN *, int, CHAIN **); 00064 void DISK2CHAIN (char *, CHAIN **); 00065 void CHAIN_COMPUTE_COORDINATES (int, int, unsigned char, int *, int *); 00066 void CHAIN_COMPUTE_CODE (int , int , int , int , unsigned char *); 00067 void CHAIN_RINGWIDTHS (IMAGE_BYTE *, MOSAIC_INDEX *, CHAIN *, IMAGE_BYTE **, int *, double **); 00068 void SYNTHESIZE_INSERT_RING (CHAIN *, int, int, int);