summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c647
1 files changed, 0 insertions, 647 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c
deleted file mode 100755
index 98b377d..0000000
--- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/MEX/edges.c
+++ /dev/null
@@ -1,647 +0,0 @@
1/*
2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3;;; File: edges.c
4;;; Author: Eero Simoncelli
5;;; Description: Boundary handling routines for use with convolve.c
6;;; Creation Date: Spring 1987.
7;;; MODIFIED, 6/96, to operate on double float arrays.
8;;; MODIFIED by dgp, 4/1/97, to support THINK C.
9;;; MODIFIED, 8/97: reflect1, reflect2, repeat, extend upgraded to
10;;; work properly for non-symmetric filters. Added qreflect2 to handle
11;;; even-length QMF's which broke under the reflect2 modification.
12;;; ----------------------------------------------------------------
13;;; Object-Based Vision and Image Understanding System (OBVIUS),
14;;; Copyright 1988, Vision Science Group, Media Laboratory,
15;;; Massachusetts Institute of Technology.
16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17*/
18
19/* This file contains functions which determine how edges are to be
20handled when performing convolutions of images with linear filters.
21Any edge handling function which is local and linear may be defined,
22except (unfortunately) constants cannot be added. So to treat the
23edges as if the image is surrounded by a gray field, you must paste it
24into a gray image, convolve, and crop it out... The main convolution
25functions are called internal_reduce and internal_expand and are
26defined in the file convolve.c. The idea is that the convolution
27function calls the edge handling function which computes a new filter
28based on the old filter and the distance to the edge of the image.
29For example, reflection is done by reflecting the filter through the
30appropriate axis and summing. Currently defined functions are listed
31below.
32*/
33
34
35#include <stdio.h>
36#include <math.h>
37#include <string.h>
38#include "convolve.h"
39
40#define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) )
41#define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) )
42
43int reflect1(), reflect2(), qreflect2(), repeat(), zero(), Extend(), nocompute();
44int ereflect(), predict();
45
46/* Lookup table matching a descriptive string to the edge-handling function */
47#if !THINK_C
48 static EDGE_HANDLER edge_foos[] =
49 {
50 { "dont-compute", nocompute }, /* zero output for filter touching edge */
51 { "zero", zero }, /* zero outside of image */
52 { "repeat", repeat }, /* repeat edge pixel */
53 { "reflect1", reflect1 }, /* reflect about edge pixels */
54 { "reflect2", reflect2 }, /* reflect image, including edge pixels */
55 { "qreflect2", qreflect2 }, /* reflect image, including edge pixels
56 for even-length QMF decompositions */
57 { "extend", Extend }, /* extend (reflect & invert) */
58 { "ereflect", ereflect }, /* orthogonal QMF reflection */
59 };
60#else
61 /*
62 This is really stupid, but THINK C won't allow initialization of static variables in
63 a code resource with string addresses. So we do it this way.
64 The 68K code for a MATLAB 4 MEX file can only be created by THINK C.
65 However, for MATLAB 5, we'll be able to use Metrowerks CodeWarrior for both 68K and PPC, so this
66 cludge can be dropped when we drop support for MATLAB 4.
67 Denis Pelli, 4/1/97.
68 */
69 static EDGE_HANDLER edge_foos[8];
70
71 void InitializeTable(EDGE_HANDLER edge_foos[])
72 {
73 static int i=0;
74
75 if(i>0) return;
76 edge_foos[i].name="dont-compute";
77 edge_foos[i++].func=nocompute;
78 edge_foos[i].name="zero";
79 edge_foos[i++].func=zero;
80 edge_foos[i].name="repeat";
81 edge_foos[i++].func=repeat;
82 edge_foos[i].name="reflect1";
83 edge_foos[i++].func=reflect1;
84 edge_foos[i].name="reflect2";
85 edge_foos[i++].func=reflect2;
86 edge_foos[i].name="qreflect2";
87 edge_foos[i++].func=qreflect2;
88 edge_foos[i].name="extend";
89 edge_foos[i++].func=Extend;
90 edge_foos[i].name="ereflect";
91 edge_foos[i++].func=ereflect;
92 }
93#endif
94
95/*
96Function looks up an edge handler id string in the structure above, and
97returns the associated function
98*/
99fptr edge_function(char *edges)
100 {
101 int i;
102
103#if THINK_C
104 InitializeTable(edge_foos);
105#endif
106 for (i = 0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++)
107 if (strcmp(edges,edge_foos[i].name) IS 0)
108 return(edge_foos[i].func);
109 printf("Error: '%s' is not the name of a valid edge-handler!\n",edges);
110 for (i=0; i<sizeof(edge_foos)/sizeof(EDGE_HANDLER); i++)
111 {
112 if (i IS 0) printf(" Options are: ");
113 else printf(", ");
114 printf("%s",edge_foos[i].name);
115 }
116 printf("\n");
117 return(0);
118 }
119
120/*
121---------------- EDGE HANDLER ARGUMENTS ------------------------
122filt - array of filter taps.
123x_dim, y_dim - x and y dimensions of filt.
124x_pos - position of filter relative to the horizontal image edges. Negative
125 values indicate left edge, positive indicate right edge. Zero
126 indicates that the filter is not touching either edge. An absolute
127 value of 1 indicates that the edge tap of the filter is over the
128 edge pixel of the image.
129y_pos - analogous to x_pos.
130result - array where the resulting filter will go. The edge
131 of this filter will be aligned with the image for application...
132r_or_e - equal to one of the two constants EXPAND or REDUCE.
133--------------------------------------------------------------------
134*/
135
136
137/* --------------------------------------------------------------------
138nocompute() - Return zero for values where filter hangs over the edge.
139*/
140
141int nocompute(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e)
142 register double *filt, *result;
143 register int x_dim;
144 int y_dim, x_pos, y_pos, r_or_e;
145 {
146 register int i;
147 register int size = x_dim*y_dim;
148
149 if ( (x_pos>1) OR (x_pos<-1) OR (y_pos>1) OR (y_pos<-1) )
150 for (i=0; i<size; i++) result[i] = 0.0;
151 else
152 for (i=0; i<size; i++) result[i] = filt[i];
153
154 return(0);
155 }
156
157/* --------------------------------------------------------------------
158zero() - Zero outside of image. Discontinuous, but adds zero energy. */
159
160int zero(filt,x_dim,y_dim,x_pos,y_pos,result,r_or_e)
161 register double *filt, *result;
162 register int x_dim;
163 int y_dim, x_pos, y_pos, r_or_e;
164 {
165 register int y_filt,x_filt, y_res,x_res;
166 int filt_sz = x_dim*y_dim;
167 int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0));
168 int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0));
169 int i;
170
171 for (i=0; i<filt_sz; i++) result[i] = 0.0;
172
173 for (y_filt=0, y_res=y_start;
174 y_filt<filt_sz;
175 y_filt+=x_dim, y_res+=x_dim)
176 if ((y_res >= 0) AND (y_res < filt_sz))
177 for (x_filt=y_filt, x_res=x_start;
178 x_filt<y_filt+x_dim;
179 x_filt++, x_res++)
180 if ((x_res >= 0) AND (x_res < x_dim))