-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathhalftone.c
More file actions
executable file
·100 lines (86 loc) · 2.6 KB
/
halftone.c
File metadata and controls
executable file
·100 lines (86 loc) · 2.6 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
/***********************************************
*
* file halftone.c
*
* Functions: This file contains
* main
*
* Purpose:
* This file contains the main calling
* routine that performs histogram
* equalization.
*
* External Calls:
* imageio.c - create_image_file
* read_image_array
* write_image_array
* get_image_size
* allocate_image_array
* free_image_array
* does_not_exist
* ht.c - half_tone
*
* Modifications:
* 30 September 1998 - created to work with
* all I O routines in imageio.c.
*
*************************************************/
#include "cips.h"
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 half_tone();
int main(argc, argv)
int argc;
char *argv[];
{
char in_name[MAX_NAME_LENGTH];
char out_name[MAX_NAME_LENGTH];
int i;
long height, width;
short **the_image, **out_image;
short threshold;
/******************************************
*
* Ensure the command line is correct.
*
******************************************/
if(argc != 4){
printf(
"\nusage: halftone input-image output-image threshold\n");
exit(0);
}
strcpy(in_name, argv[1]);
strcpy(out_name, argv[2]);
threshold = atoi(argv[3]);
/******************************************
*
* Ensure the input image exists.
* Create the output image file.
* Allocate an image array, read the input
* image, half_tone it, and write
* the result.
*
******************************************/
if(does_not_exist(in_name)){
printf("\nERROR input file %s does not exist",
in_name);
printf("\n "
"usage: histeq input-image output-image");
exit(0);
} /* ends if does_not_exist */
create_image_file(in_name, out_name);
get_image_size(in_name, &height, &width);
the_image = allocate_image_array(height, width);
out_image = allocate_image_array(height, width);
read_image_array(in_name, the_image);
half_tone(the_image, out_image,
threshold, 200, 0,
height, width);
write_image_array(out_name, out_image);
free_image_array(the_image, height);
free_image_array(out_image, height);
} /* ends main */