forked from Dwayne-Phillips/CIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddsub.c
More file actions
executable file
·85 lines (69 loc) · 2.02 KB
/
addsub.c
File metadata and controls
executable file
·85 lines (69 loc) · 2.02 KB
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
/***********************************************
*
* file addsub.c
*
* Functions: This file contains
* add_image_array
* subtract_image_array
*
* Purpose:
* These functions implement
* image addition and subtraction.
*
* External Calls:
* none
*
* Modifications:
* 1 April 1992 - created
*
*************************************************/
#include "cips.h"
/*******************************************
*
* add_image_array(...
*
* This function adds two image arrays.
* The image array out_image will hold
* the result.
*
*******************************************/
int add_image_array(the_image, out_image, rows, cols, max)
int rows, cols;
short **the_image,
**out_image,
max;
{
int i, j;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
out_image[i][j] = the_image[i][j] +
out_image[i][j];
if(out_image[i][j] > max)
out_image[i][j] = max;
} /* ends loop over j */
} /* ends loop over i */
} /* ends add_image_array */
/*******************************************
*
* subtract_image_array(...
*
* This function subtracts two image arrays.
* The image array out_image will hold
* the result.
*
*******************************************/
int subtract_image_array(the_image, out_image, rows, cols)
int rows, cols;
short **the_image,
**out_image;
{
int i, j, length, width;
for(i=0; i<rows; i++){
for(j=0; j<cols; j++){
out_image[i][j] = the_image[i][j] -
out_image[i][j];
if(out_image[i][j] < 0)
out_image[i][j] = 0;
} /* ends loop over j */
} /* ends loop over i */
} /* ends subtract_image_array */