home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
polygons.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-05
|
11KB
|
413 lines
/*
* Polygons.h
*
* Important definitions for the perceptual grouping routines
* used in the building detector.
*
* Christopher Jaynes
* March, 10 1995
* ASCENDER System
*
* UMass RADIUS-VISIONS Group.
*
*
*/
#include <stdio.h>
#include <math.h>
#include "rcde_types.h"
#define TRUE 1
#define FALSE 0
#define LINE_WIDTH 2
#define SQ(x) ((x)*(x))
#define PI 3.141
#define MB1_SCALE (500.0/12.0)
char IMAGE_NAME[80];
char IMAGE_NAME_3D[80];
#define LOW 0
#define MEDIUM 1
#define HIGH 2
#define EMPTY 0
#define USED 1
#define LINE 3
#define NONE 0
#define MAXCHAINLEN 8
#define WINDOW 8
#define MIN_LINE_LENGTH 5
#define MAX_ALLOWED_COLOR 700 /* Was 550, max search depth in FRG */
#define IMAGE_VAR 1.5 /* Expected error, in pixels */
#define DEFAULT_ANGLE_THRESH_HIGH 0.25 /* 14.3 degrees */
#define DEFAULT_LINE_SUPPORT_HIGH 0.5
#define TOKEN_SUPPORT_HIGH 0.5
#define TOKEN_WINDOW_HIGH 8
#define LINE_SWEEP_COLUMN_HIGH 6
#define LINE_ENDPOINT_WINDOW_HIGH 12.0
#define DEFAULT_LINE_SUPPORT_MEDIUM 0.7
#define TOKEN_SUPPORT_MEDIUM 0.7
#define TOKEN_WINDOW_MEDIUM 4
#define DEFAULT_ANGLE_THRESH_LOW 0.05 /* 2.8 degrees */
#define DEFAULT_LINE_SUPPORT_LOW 0.9
#define TOKEN_SUPPORT_LOW 0.75
#define TOKEN_WINDOW_LOW 1
#define LINE_SWEEP_COLUMN_LOW 3
#define LINE_ENDPOINT_WINDOW_LOW 1.0
#define DEFAULT_SEARCH_ANGLE 0.001
#define DEFAULT_ANGLE_THRESH 0.098
#define LINE_SEARCH_DIST 500
#define XPOS 103
#define YPOS 104
#define AXIS1 105
#define AXIS2 106
#define X 1
#define Y 2
#define OPEN 0
#define CLOSED 1
extern c_handle image_trans;
extern c_handle view_trans;
double ANGLE_THRESH;
double LINE_ENDPOINT_WINDOW;
int CONSTRAIN;
int K_CYCLES;
int LINE_SWEEP_COLUMN;
double SEARCH_ANGLE;
double MIN_LINE_SUPPORT;
double TOKEN_SUPPORT;
double TOKEN_WINDOW;
double MIN_ROOF_HEIGHT;
double MAX_ROOF_HEIGHT;
int xstart, ystart, xstop, ystop;
typedef double mat_4x4[4][4];
typedef double mat_4x1[4];
typedef struct e {
float confidence;
int type;
struct l *vertex;
struct e *next;
int position;
int dir;
} edgeList;
typedef struct co {
int color;
struct co *next;
} colorList;
typedef struct l {
int magnitude;
colorList *colors;
long int P; /* Polygon bit set. */
int depth;
edgeList *eList;
int x;
int y;
double xpos,ypos;
double leg1Dx, leg1Dy;
double leg2Dx, leg2Dy;
int x_corr;
int y_corr;
double height;
struct l *next;
struct l *last;
} cList;
/* as backlist for the coloring */
typedef struct vl {
cList *vertex;
double confidence;
struct vl *next;
} vertexList;
typedef struct MGv {
vertexList *vList;
struct MGe *eList;
int color;
double confidence;
int isscolor;
struct MGv *next;
} MGvertex;
typedef struct MGe {
MGvertex *vertex;
struct MGe *next;
} MGedgeList;
typedef struct MGvList {
double confidence;
MGedgeList *eList;
struct MGvList *next;
} MGvertexList;
typedef struct line_node {
double x1;
double y1;
double x2;
double y2;
double contrast;
double height;
double confidence;
struct line_node *next;
} line;
typedef struct {
double x;
double x_corr;
double y;
double y_corr;
double z;
double r;
} Point;
typedef struct chain {
float chainCertainty;
int label;
int class;
int chain[MAXCHAINLEN];
struct chain *next;
} pChain;
typedef struct {
int x;
int y;
} vArray;
typedef double RotMatrix[4][4];
int xdim; /** Global value of the width of the image **/
int ydim;
cList *corner_list;
line *line_list;
int thresh;
int cornerMax;
c_handle in_pane; /** Global Pane for polygon detector **/
c_handle projectionMat;
/********* RCDE Defs for image manipulation, etc.. *******************/
extern c_handle make_image();
extern c_handle copy_image();
extern c_handle push_image();
extern c_handle_1_int_3* pick_a_pane();
struct c_handle_1_int_3* pane_choice;
struct c_handle_1_int_2* image_choice;
c_handle in_image, in_pane, out_pane, icopy, pane;
struct double_3* sun_vector();
/******* Global Procedure Defs ***************************************/
double tokenSupport(cList *c1, cList *c2);
double virtualTokenSupport(Point p, cList *c2);
void process_region(char *corners, char *lines, c_handle image);
void setup_defaults(double sensitivity);
int compute_intersections_region(char *lines, char *corners,
c_handle pane, c_handle image, int x1, int y1,int x2, int y2);
void intersect_point(line l1, line l2, double_2 *result);
void computeParms(double_2 vert, line l1, line l2, double parms[2]);
cList *read_corners_from_file(char *file);
cList *create_list(int x, int y, double h, int mag, double l1X,
double l1Y, double l2X, double l2Y);
cList *insert(cList *list, cList *ptr, int x, int y, double h, int mag,
double l1X, double l1Y, double l2X, double l2Y);
void insert_end(cList *ptr, int x, int y, double h, int mag,
double l1X, double l1Y, double l2X, double l2Y);
cList *insert_corner(cList *list,int x,int y, double h, int mag,
double l1X, double l1Y, double l2X, double l2Y);
void print_corner_list(cList *ptr);
void clear_image(c_handle image, int x1, int x2, int y1, int y2);
line *load_line_data(int startx, int starty, int stopx, int stopy,char *file,
c_handle im);
cList *sortList(cList *list);
void free_list(cList *list);
void free_line_list(line *list);
double distance(double x1, double y1, double x2, double y2);
void labelPoly(cList *ptr, int label);
int even(int x);
void free_pChains(pChain *c);
double support_val(c_handle im, cList *ptr, int *axis, int x2, int y2,
float Dx, float Dy, int *pos, int virt);
float enoughSupport(c_handle im, cList *c1, cList *c2, int axis, int *pos, int *dir);
int buildEdges(cList *ptr, cList *list, c_handle im, c_handle pane);
void buildGraph(cList *list, c_handle im, c_handle pane);
double idealX(int Dx, int Dy, RotMatrix Forward, RotMatrix Back);
double idealY(int Dx, int Dy, RotMatrix Forward, RotMatrix Back);
int cornerMatches(cList *c1, cList *c2, int axis);
double myatan(double y, double x);
void tours(c_handle im,cList *v_list,int *curr_color,MGvertex **meta_graph);
void virtualTours(c_handle im, cList *v_list, int *curr_color,
MGvertex **meta_graph);
int virtual_dfs(c_handle im, cList *list, int axis, int color, vertexList **visited_list, cList **graph, MGvertex **meta_graph, int depth);
void build_dependency_graph(cList *v_list, int color_no, MGvertex *meta_graph);
MGvertexList *indep_subset_list(MGvertex *graph);
MGvertexList *get_max_iss(MGvertexList *vertex_list);
MGvertexList *all_indep_subsets(MGvertex *graph);
double virtualSupport(c_handle im, Point *feature,
cList *vert1, int axis, cList *vert2, int *dir);
Point featureGap(cList *vertex, int axis, cList *corner);
Point TfeatureGap(cList *v1, int axis, cList *v2);
void project_3d_to_2d(char *image, double point[4],
double res_point[4]);
void project_2d_to_3d(char *image, double point[4],
double res_point[4]);
void project_2d_to_KP(char *image, double point[4], double res_point[4]);
double aref_2D_double(c_handle matrix, int i, int j);
double aref_1D_double(c_handle matrix, int i);
void
calc_next(char *image, int axis, int type, int u, int v, float *dx, float *dy);
int
buildEdge(cList *v1, cList *v2, float str, int axis, c_handle pane, int pos, int dir);
int conflictIntersection(int x1, int y1, int x2, int y2);
char *get2_5dlineFile(c_handle image);
char *get2dlineFile(c_handle image);
char *getTempDir(c_handle image);
double perfectX(cList *c1, cList *c2);
double perfectY(cList *c1, cList *c2);
double transLine(int line, cList *c1);
void write_corners_to_file(char *fname, cList *ptr);
int sum_at(c_handle im, int x1, int y1);
int sqsum_at(c_handle im, int x1, int y1);
void setupGridRotation(double f, double b);
double angleBetween(line l1, line l2);
float IntersectLines(line l1, line l2, double p[2]);
int linesProximate(line l1, line l2);
int linesOverlap(line l1, line l2);
double lineOverlaps(line l1, line l2);
double distancePointLine(Point p, line l);
double distancePointLineHessian(Point p, line l);
double LineLength(double StartCol, double StartRow, double EndCol, double EndRow);
void getParametricPoint(line l, double t, Point *p);
int LineSegColIntercept(double StartCol,
double StartRow,
double EndCol,
double EndRow,
double *ColIntercept);
int LineSegRowIntercept(double StartCol,
double StartRow,
double EndCol,
double EndRow,
double *RowIntercept);
double PtLinePerpDistance( double PtCol,
double PtRow,
double ColIntercept,
double RowIntercept,
double Theta);
int PtLinePerpIntercept(double PtCol,
double PtRow,
double ColIntercept,
double RowIntercept,
double Theta,
double *InterceptPtCol,
double *InterceptPtRow);
double LineSegTheta(double StartCol,
double StartRow,
double EndCol,
double EndRow);
int CheckPtParlLineSeg(double PtCol,
double PtRow,
double LengthParlVar,
double LengthPerpVar,
double Length,
double Theta,
double StartCol,
double StartRow,
double EndCol,
double EndRow);
double projectAngle(char *image, double a);
int IntersectType(double t, double s);
float **matrix(int nrl,int nrh,int ncl,int nch);
float *vector(int nl,int nh);
void Local_ludcmp(float **a,int n,int *indx,float *d);
void Local_lubksb(float **a,int n,int *indx,float b[]);
void Local_free_vector(float *v,int nl,int nh);
void Local_free_matrix(float **m,int nrl,int nrh,int ncl,int nch);
int linkedByEdge(cList *p1, cList *p2);
double image_line_support(int c_handle, double x1, double y1,
double x2, double y2, double col,
double percentage);
MGvertexList *sort_top_K_nodes(MGvertex *meta_graph, int k);
MGvertex *get_max_MG(MGvertex *graph, double max, double *new);