forked from Dwayne-Phillips/CIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiii.c
executable file
·175 lines (142 loc) · 4.04 KB
/
iii.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
/***********************************************
*
* file iii.c
*
* Functions: This file contains
* main
*
* Purpose:
* This is a test program.
*
* External Calls:
* imageio.c
* create_allocate_tif_file
* create_allocate_bmp_file
* get_image_size
* allocate_image_array
* free_image_array
* read_image_array
* write_image_array
*
* Modifications:
* 18 February 2016 - created
*
***********************************************/
#include "cips.h"
int grow();
int does_not_exist();
int create_image_file();
int get_image_size();
int read_image_array();
int free_image_array();
int write_image_array();
int create_allocate_tiff_file();
int create_allocate_bmp_file();
int main(argc, argv)
int argc;
char *argv[];
{
char name1[80], name2[80];
char *cc;
int a, b;
int ok = 0;
long length, width;
short **the_image;
struct tiff_header_struct image_header;
struct bmpfileheader bmp_file_header;
struct bitmapheader bmheader;
if(argc != 3){
printf("\nusage: III-TEST-PROGRAM in-file out-file\n");
exit(1);
}
strcpy(name1, argv[1]);
strcpy(name2, argv[2]);
get_image_size(name1, &length, &width);
the_image = allocate_image_array(length, width);
cc = strstr(name1, ".tif");
if(cc != NULL){ /* create a tif */
ok = 1;
image_header.lsb = 1;
image_header.bits_per_pixel = 8;
image_header.image_length = length;
image_header.image_width = width;
image_header.strip_offset = 1000;
create_allocate_tiff_file(name2,
&image_header);
} /* ends tif */
cc = strstr(argv[1], ".bmp");
if(cc != NULL){ /* create a bmp */
ok = 1;
bmheader.height = length;
bmheader.width = width;
create_allocate_bmp_file(argv[2],
&bmp_file_header,
&bmheader);
} /* ends tif */
if(ok == 0){
printf("\nERROR input file neither tiff nor bmp");
exit(0);
}
read_image_array(name1, the_image);
/************
for(a=0; a<length; a++){
for(b=0; b<width; b++){
the_image[a][b] = 0;
}
}
for(a=0; a<length; a++){
for(b=0; b<width; b++){
if(a % 50 == 0 && b % 50 == 0)
the_image[a][b] = 100;
}
}
for(a=0; a<length; a++){
for(b=0; b<width; b++){
the_image[a][b] = 0;
}
}
for(a=10; a<50; a++)
for(b=10; b<50; b++)
the_image[a][b] = 100;
for(a=110; a<150; a++)
for(b=110; b<150; b++)
the_image[a][b] = 100;
for(a=210; a<250; a++)
for(b=210; b<250; b++)
the_image[a][b] = 100;
for(a=310; a<350; a++)
for(b=310; b<350; b++)
the_image[a][b] = 100;
for(a=10; a<50; a++)
for(b=60; b<110; b++)
the_image[a][b] = 100;
for(a=10; a<50; a++)
for(b=120; b<170; b++)
the_image[a][b] = 100;
for(a=10; a<50; a++)
for(b=180; b<230; b++)
the_image[a][b] = 100;
for(a=10; a<50; a++)
for(b=240; b<290; b++)
the_image[a][b] = 100;
for(a=10; a<50; a++)
for(b=300; b<350; b++)
the_image[a][b] = 100;
for(a=360; a<365; a++)
for(b=360; b<365; b++)
the_image[a][b] = 100;
for(a=370; a<375; a++)
for(b=370; b<375; b++)
the_image[a][b] = 100;
for(a=380; a<385; a++)
for(b=380; b<385; b++)
the_image[a][b] = 100;
the_image[390][390] = 100;
the_image[392][392] = 100;
the_image[394][394] = 100;
the_image[396][396] = 100;
***************/
grow(the_image, 100, length, width);
write_image_array(name2, the_image);
free_image_array(the_image, length);
} /* ends main */