summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c494
1 files changed, 0 insertions, 494 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c b/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c
deleted file mode 100755
index 1f6a98b..0000000
--- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/edges-orig.c
+++ /dev/null
@@ -1,494 +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;;; ----------------------------------------------------------------
10;;; Object-Based Vision and Image Understanding System (OBVIUS),
11;;; Copyright 1988, Vision Science Group, Media Laboratory,
12;;; Massachusetts Institute of Technology.
13;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14*/
15
16/*
17This file contains functions which determine how edges are to be
18handled when performing convolutions of images with linear filters.
19Any edge handling function which is local and linear may be defined,
20except (unfortunately) constants cannot be added. So to treat the
21edges as if the image is surrounded by a gray field, you must paste it
22into a gray image, convolve, and crop it out...
23The main convolution function is called internal_filter and is defined
24in the file convolve.c. The idea is that the convolution function
25calls the edge handling function which computes a new filter based on
26the old filter and the distance to the edge of the image. For
27example, reflection is done by reflecting the filter through the
28appropriate axis and summing. Currently defined functions are listed
29below.
30*/
31
32/*
33#define DEBUG
34*/
35
36#include <stdio.h>
37#include <math.h>
38#include <string.h>
39#include "convolve.h"
40
41#define sgn(a) ( ((a)>0)?1:(((a)<0)?-1:0) )
42#define clip(a,mn,mx) ( ((a)<(mn))?(mn):(((a)>=(mx))?(mx-1):(a)) )
43
44int reflect1(), reflect2(), repeat(), zero(), Extend(), nocompute();
45int ereflect(), predict();
46
47/* Lookup table matching a descriptive string to the edge-handling function */
48#if !THINK_C
49 static EDGE_HANDLER edge_foos[] =
50 {
51 { "dont-compute", nocompute }, /* zero output for filter touching edge */
52 { "zero", zero }, /* zero outside of image */
53 { "repeat", repeat }, /* repeat edge pixel */
54 { "reflect1", reflect1 }, /* reflect about edge pixels */
55 { "reflect2", reflect2 }, /* reflect image, including edge pixels */
56 { "extend", Extend }, /* extend (reflect & invert) */
57 { "predict", predict }, /* predict based on portion covered by filt */
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="extend";
87 edge_foos[i++].func=Extend;
88 edge_foos[i].name="predict";
89 edge_foos[i++].func=predict;
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) == 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==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...
132f_or_e - equal to one of the two constants EXPAND or FILTER.
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,f_or_e)
142 register double *filt, *result;
143 register int x_dim;
144 int y_dim, x_pos, y_pos, f_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 return(0);
154 }
155
156/* --------------------------------------------------------------------
157zero() - Zero outside of image. Discontinuous, but adds zero energy. */
158
159int zero(filt,x_dim,y_dim,x_pos,y_pos,result,f_or_e)
160 register double *filt, *result;
161 register int x_dim;
162 int y_dim, x_pos, y_pos, f_or_e;
163 {
164 register int y_filt,x_filt, y_res,x_res;
165 int filt_sz = x_dim*y_dim;
166 int x_start = ((x_pos>0)?(x_pos-1):((x_pos<0)?(x_pos+1):0));
167 int y_start = x_dim * ((y_pos>0)?(y_pos-1):((y_pos<0)?(y_pos+1):0));
168 int i;
169
170 for (i=0; i<filt_sz; i++) result[i] = 0.0;
171
172 for (y_filt=0, y_res=y_start;
173 y_filt<filt_sz;
174 y_filt+=x_dim, y_res+=x_dim)
175 if ((y_res >= 0) AND (y_res < filt_sz))
176 for (x_filt=y_filt, x_res=x_start;
177 x_filt<y_filt+x_dim;
178 x_filt++, x_res++)
179 if ((x_res >= 0) AND (x_res < x_dim))
180 result[y_res+x_res] = filt[x_filt];
181 return(0);