-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathoverlay.c
executable file
·194 lines (156 loc) · 4.59 KB
/
overlay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*********************************************
*
* file overlay.c
*
* Functions: This file contains
* non_zero_overlay
* zero_overlay
* greater_overlay
* less_overlay
* average_overlay
*
* Purpose:
* These functions implement the
* functions that overlay one image
* on top of another image.
*
* External Calls:
* none
*
* Modifications:
* 6 March 1993 - created
* 22 August 1998 - modified to work on
* entire images at once.
*
*********************************************/
#include "cips.h"
/**********************************************
*
* non_zero_overlay(...
*
* This function overlays in1 on top of in2
* and writes the result to the output image.
* It writes any non-zero pixel from in1 on top
* of in2.
*
***********************************************/
int non_zero_overlay(the_image, out_image,
rows, cols)
short **the_image,
**out_image;
long cols, rows;
{
int i, j;
for(i=0; i<rows; i++){
if ( (i%10) == 0) printf(" %d", i);
for(j=0; j<cols; j++){
if(the_image[i][j] != 0)
out_image[i][j] = the_image[i][j];
} /* ends loop over j */
} /* ends loop over i */
return(1);
} /* ends non_zero_overlay */
/**********************************************
*
* zero_overlay(...
*
* This function overlays in1 on top of in2
* and writes the result to the output image.
* It writes any zero pixel from in1 on top
* of in2.
*
***********************************************/
int zero_overlay(the_image, out_image,
rows, cols)
short **the_image,
**out_image;
long cols, rows;
{
int i, j;
for(i=0; i<rows; i++){
if ( (i%10) == 0) printf(" %d", i);
for(j=0; j<cols; j++){
if(the_image[i][j] == 0)
out_image[i][j] = the_image[i][j];
} /* ends loop over j */
} /* ends loop over i */
return(1);
} /* ends zero_overlay */
/**********************************************
*
* greater_overlay(...
*
* This function overlays in1 on top of in2
* and writes the result to the output image.
* It writes in1 on top of in2 if the value of
* in1 is greater than in2.
*
***********************************************/
int greater_overlay(the_image, out_image,
rows, cols)
short **the_image,
**out_image;
long cols, rows;
{
int i, j;
for(i=0; i<rows; i++){
if ( (i%10) == 0) printf(" %d", i);
for(j=0; j<cols; j++){
if(the_image[i][j] > out_image[i][j])
out_image[i][j] = the_image[i][j];
} /* ends loop over j */
} /* ends loop over i */
return(1);
} /* ends greater_overlay */
/**********************************************
*
* less_overlay(...
*
* This function overlays in1 on top of in2
* and writes the result to the output image.
* It writes in1 on top of in2 if the value of
* in1 is less than in2.
*
***********************************************/
int less_overlay(the_image, out_image,
rows, cols)
short **the_image,
**out_image;
long cols, rows;
{
int i, j;
for(i=0; i<rows; i++){
if ( (i%10) == 0) printf(" %d", i);
for(j=0; j<cols; j++){
if(the_image[i][j] < out_image[i][j])
out_image[i][j] = the_image[i][j];
} /* ends loop over j */
} /* ends loop over i */
return(1);
} /* ends less_overlay */
/**********************************************
*
* average_overlay(...
*
* This function mixes in1 and in2
* and writes the result to the output image.
* It writes the average of in1 and in2 to the
* output image.
*
***********************************************/
int average_overlay(the_image, out_image,
rows, cols)
short **the_image,
**out_image;
long cols, rows;
{
int i, j;
for(i=0; i<rows; i++){
if ( (i%10) == 0) printf(" %d", i);
for(j=0; j<cols; j++){
out_image[i][j] =
(the_image[i][j] + out_image[i][j])/2;
} /* ends loop over j */
} /* ends loop over i */
return(1);
} /* ends average_overlay */