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
/
support.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-30
|
5KB
|
239 lines
#include "../polygons.h"
/**
float sweep_mask(c_handle im, int x, int y, int width, int len,
float Dx, float Dy, int *maxPos, int virt,
int *dir);
float convolve_at(c_handle im, int x, int y, int len,
float Dx, float Dy);
**/
int calcDelta(c_handle im, int x, int y, int axis);
int mask[5];
double support_val(c_handle im, cList *ptr, int *axis, int x2, int y2,
float Dx, float Dy, int *pos, int virt)
/*****
Calculate the underlying edge support the lies in the intensity
plane from the corner at 'ptr' and (x1,y1).
This should be done by construction of a local edge template
and looking at the intensity plane for a gradient.
However, right now, simply search for a local corner point
compute the overlap of that line projected onto the hypothesized
edge.
******/
{
int dir;
double s_val;
int i;
/** First Check for another line that intersects the "proposed"
one, with an angle close to 90 degrees **/
if (distance(ptr->x,ptr->y,x2,y2) > MIN_LINE_LENGTH) {
if (!conflictIntersection(ptr->x,ptr->y,x2,y2) || virt) {
/*** VIRTUAL FEATURE SUPPORT ONLY REQUIRES THAT THE SUM OF THE
SUPPORTS Be > MIN_LINE_SUPPORT ***/
if (virt)
s_val = (double) image_line_support(im,(double)ptr->x,
(double)ptr->y,
(double)x2,(double)y2,(double)LINE_SWEEP_COLUMN,
0.0);
else
s_val = (double) image_line_support(im,(double)ptr->x,
(double)ptr->y,
(double)x2,(double)y2,(double)LINE_SWEEP_COLUMN,
MIN_LINE_SUPPORT);
}
else {
s_val = 0.0;
}
} else
s_val = 0.0;
return(s_val);
}
double virtualSupport(c_handle im, Point *feature,
cList *vert1, int axis, cList *vert2, int *dir)
{
/*** Is there enough edge support for a virtual feature to be
created at (feature.x,feature.y)? Check both corners against
the new feature and the intensity gradient of the lines between
them. If they both pass MIN_EDGE_SUPPORT, then return the sum
of the supports.
***/
double support1, support2;
float Dx, Dy;
int pos1, pos2;
int axis2;
/*** swap the axis, because we are looking forward from the dfs
search axis. **/
if (axis == AXIS1)
axis = AXIS2;
else
axis = AXIS1;
if (axis == AXIS1) {
Dx = vert1->leg1Dx;
Dy = vert1->leg1Dy;
}
else {
Dx = vert1->leg2Dx;
Dy = vert1->leg2Dy;
}
/*
* NOTE: pos1, and pos2 are unused as of version 1.0
* in the future they will be use to set the correct
* corner location according to the maximum edge response
*/
pos1 = 0;
pos2 = 0;
support1 = support_val(im,vert1,dir,(int)floor(feature->x),
(int)floor(feature->y), Dx, Dy,
&pos1, 1);
/** We know that vert2 must have a different axis type **/
if (axis == AXIS1)
axis = AXIS2;
else
axis = AXIS1;
if (axis == AXIS1) {
Dx = vert2->leg1Dx;
Dy = vert2->leg1Dy;
}
else {
Dx = vert2->leg2Dx;
Dy = vert2->leg2Dy;
}
support2 = support_val(im,vert2,dir,(int)floor(feature->x),
(int)floor(feature->y),Dx,Dy, &pos2, 1);
if ( ((support1+support2)/2.0) > MIN_LINE_SUPPORT) {
(int)feature->x_corr = (int)feature->x + pos1;
(int)feature->y_corr = (int)feature->y + pos2;
return((support1 + support2)/2.0);
}
else {
(int)feature->x_corr = -1;
(int)feature->y_corr = -1;
return(0.0);
}
}
void
calc_line_direction(char *image, int u1, int v1, int u2, int v2,
float *dx, float *dy)
{
/*** Project the (u,v) co-ordinates into 3D and take a step
in the direction indicated by type and axis. Project
the 3D result into the image. ***/
mat_4x1 vec1;
mat_4x1 vec2;
double StepX, StepY;
/***********
vec1[0] = (double) u1; vec2[0] = (double) u2;
vec1[1] = (double) v1; vec2[1] = (double) v2;
vec1[2] = 0.0; vec2[2] = 0.0;
vec1[3] = 1.0; vec2[3] = 1.0;
project_2d_to_3d(image,vec1,vec1);
project_2d_to_3d(image,vec2,vec2);
StepX = vec2[0] - vec1[0];
StepY = vec2[1] - vec1[1];
vec1[0] = vec1[0] + StepX;
vec1[1] = vec1[1] + StepY;
project_3d_to_2d(image,vec1,vec1);
***********/
StepX = (double)(u2 - u1);
StepY = (double)(v2 - v1);
if (fabs(StepX) > fabs(StepY) ) {
if (StepX < 0)
*dx = -1.0;
else
*dx = 1.0;
*dy = (StepY/fabs(StepX));
}
else {
if (StepY < 0)
*dy = -1.0;
else
*dy = 1.0;
*dx = (StepX / fabs(StepY));
}
/** Normalize the Line length with respect to the maximum change
to compute a Delta X, Delta Y for line following ...
if (fabs(vec1[0]) > fabs(vec1[0]) ) {
if (vec1[0] < 0)
*dx = -1.0;
else
*dx = 1.0;
*dy = (vec1[1]/fabs(vec1[0]));
}
else {
if (vec1[1] < 0)
*dy = -1.0;
else
*dy = 1.0;
*dx = (vec1[0] / fabs(vec1[1]));
}
***/
}
int calcDelta(c_handle im, int x, int y, int axis)
{
int delta;
if (axis == X) {
delta = iref_int(im,(int)x,(int)y-2)*mask[0];
delta += iref_int(im,(int)x,(int)y-1)*mask[1];
delta += iref_int(im,(int)x,(int)y)*mask[2];
delta += iref_int(im,(int)x,(int)y+1)*mask[3];
delta += iref_int(im,(int)x,(int)y+2)*mask[4];
} else {
delta = iref_int(im,(int)x-2,(int)y)*mask[0];
delta += iref_int(im,(int)x-1,(int)y)*mask[1];
delta += iref_int(im,(int)x,(int)y)*mask[2];
delta += iref_int(im,(int)x+1,(int)y)*mask[3];
delta += iref_int(im,(int)x+2,(int)y)*mask[4];
}
return(delta);
}