-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakevim.c
More file actions
145 lines (125 loc) · 3.72 KB
/
makevim.c
File metadata and controls
145 lines (125 loc) · 3.72 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
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
/*********************************************************/
/** makevim **/
/** generates a blank image of a certain value **/
/** **/
/** -o file output image file **/
/** -v value value **/
/** -x size image x size **/
/** -y size image y size **/
/** -z size image z size **/
/** -d display also **/
/** -dx loc display x location **/
/** -dy loc display y location **/
/** -dh value display high value (255?) **/
/** -dl value display low value (0?) **/
/** -c string comment string **/
/** -Z val zoom image x val **/
/** -e equalize image [0-255] **/
/** -s value saturate image decay (10 - 400) **/
/** -m value multiply by scaling constant **/
/** -k value add constant **/
/** -t val threshold image at val **/
/** -b convert output to byte image **/
/** -q quiet (no run-time printing) **/
/*********************************************************/
#include "maineye.h"
#include <stdlib.h>
main(argc,argv)
int argc;
char **argv;
{
image_type *img;
int arg,intval();
char *stringval();
float floatval();
int xsize,ysize,zsize;
/**** initialize dimensions ****/
if(is_arg("-x",argc,argv)) xsize = intval("-x",argc,argv); else xsize=128;
if(is_arg("-y",argc,argv)) ysize = intval("-y",argc,argv); else ysize=128;
if(is_arg("-z",argc,argv)) zsize = intval("-z",argc,argv); else zsize=1;
/**** create image ****/
img = make_img(stringval("-o",argc,argv),stringval("-c",argc,argv),
IMAGE,xsize,ysize,zsize);
/**** color image ****/
color_img(img,floatval("-v",argc,argv));
/**** ramp image ****/
if(is_arg("-ramp",argc,argv)) ramp_img(img);
/**** randomize image ****/
if(is_arg("-rand",argc,argv)) rand_img(img);
/**** process image ****/
process_img(img,argc,argv);
//if(is_arg("-d",argc,argv)) display_img( img);
if(is_arg("-o",argc,argv)) write_img( img);
}
/*********************************************************/
/** color image **/
/** generates a featureless image of value color **/
/*********************************************************/
color_img(img,color)
image_type *img;
float color;
{
register int x,y,z,xsize,ysize,zsize;
int i,x1,x2,y1,y2;
/**** initialize ****/
if(img==NULL){fprintf(stderr,"ERROR color_img: img=NULL\n"); exit(1);}
xsize = img->xsize;
ysize = img->ysize;
zsize = img->zsize;
/**** color background ****/
for(z=0;z<zsize;z++){
for(y=0;y<ysize;y++){
for(x=0;x<xsize;x++){
AREF3(img->data,z,y,x,ysize,xsize) = color;
}
}
}
}
/*********************************************************/
/** rand image **/
/** adds rand() noise to image **/
/*********************************************************/
rand_img(img)
image_type *img;
{
register int x,y,z,xsize,ysize,zsize;
int i,x1,x2,y1,y2;
double drand48();
void srand48();
/**** initialize ****/
if(img==NULL){fprintf(stderr,"ERROR rand_img: img=NULL\n"); exit(1);}
xsize = img->xsize;
ysize = img->ysize;
zsize = img->zsize;
/**** rand background ****/
for(z=0;z<zsize;z++){
for(y=0;y<ysize;y++){
for(x=0;x<xsize;x++){
AREF3(img->data,z,y,x,ysize,xsize) *= drand48();
}
}
}
}
/*********************************************************/
/** ramp image **/
/** generates a ramp image **/
/*********************************************************/
ramp_img(img)
image_type *img;
{
register int x,y,z,xsize,ysize,zsize;
int i,x1,x2,y1,y2;
/**** initialize ****/
if(img==NULL){fprintf(stderr,"ERROR ramp_img: img=NULL\n"); exit(1);}
xsize = img->xsize;
ysize = img->ysize;
zsize = img->zsize;
/**** ramp ****/
for(z=0;z<zsize;z++){
for(y=0;y<ysize;y++){
for(x=0;x<xsize;x++){
AREF3(img->data,z,y,x,ysize,xsize) = x;
}
}
}
}