41
406
APPENDIX F. SOURCE CODE LISTINGS
}
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 */
Listing 3.2 - The main Routine for the Halftone Program