PROTO
proto - this is a prototype KUIM program.
Synopsis
proto [options] infile outfile
[-d] Debugging flag.
Description
This program reads the input image and simply
writes the image to the output file. The program
is intended to be a prototype illustrating the
usage of most basic KUIM image access routines.
Each of the calls to the KUIM library below have
links to corresponding manual pages.
Example
/*---------------------------------------------------------------------------*/
/* */
/* Program: proto.c */
/* */
/* Purpose: This is a prototype image processing program for a new */
/* image format called KUIM. This program simply reads in */
/* an image in FLOAT format and copies the data to an image */
/* in FLOAT format. Type conversion to FLOAT is automatic */
/* and part of im_read(). */
/* */
/* Author: John Gauch */
/* */
/* Date: March 23, 1994 */
/* */
/* Note: Copyright (C) The University of Kansas, 1994 */
/*---------------------------------------------------------------------------*/
#include < IM.h >
main(argc, argv)
int argc;
char *argv[];
{
/* Image variables */
char Name1[50];
char Name2[50];
IM_TYPE *Image1;
IM_TYPE *Image2;
FLOAT_TYPE **Data1;
FLOAT_TYPE **Data2;
int PixType, Xdim, Ydim, Zdim, DimCnt;
/* Program variables */
int Debug = FALSE;
int Number;
int i=0,x,y;
/* Interpret program options */
printf("PROTO Program - KUIM Version 1.0\n\n");
while ((++i < argc) && (argv[i][0] == '-'))
switch (argv[i][1])
{
case 'n':
if (sscanf(argv[++i], "%d", &Number)==0)
Error("Could not get integer argument");
break;
case 'd':
Debug = TRUE;
break;
default:
Error("Invalid option encountered");
break;
}
/* Check number of file names */
if (argc-i != 2) {
fprintf(stderr,"Usage: proto [options] infile outfile\n");
fprintf(stderr," [-d] Print debugging information\n");
fprintf(stderr," [-n #] Integer program argument\n");
exit(1);}
/* Get image file names from argument list */
if (sscanf(argv[i++],"%s",Name1)==0)
Error("Could not get input file name");
if (sscanf(argv[i++],"%s",Name2)==0)
Error("Could not get output file name");
/* Read input image */
Image1 = im_open(Name1, &PixType, &Xdim, &Ydim, &Zdim, &DimCnt);
if (DimCnt != 2) Error("Can not process 1D or 3D images");
Data1 = (FLOAT_TYPE **)im_alloc2D(Image1, FLOAT);
im_read(Image1, FLOAT, &(Data1[0][0]));
/* Create output image */
Image2 = im_create(Name2, FLOAT, Xdim, Ydim, Zdim);
Data2 = (FLOAT_TYPE **)im_alloc2D(Image2, FLOAT);
/* Manipulate input image data */
for (y=0; y < Ydim; y++)
for (x=0; x < Xdim; x++)
Data2[y][x] = Data1[y][x];
/* Write information to output image */
im_write(Image2, FLOAT, &(Data2[0][0]));
im_free2D(Data1);
im_free2D(Data2);
exit(0);
}
Files
Source is in $KUIM/src/proto
See Also
im_create, im_open, im_read, im_write, im_get_title, im_put_title,
im_get_cmap, im_put_cmap, im_alloc1D, im_alloc2D, im_alloc3D,
im_free1D, im_free2D, im_free3D.
Author
John M. Gauch
Electrical Engineering and Computer Science
University of Kansas
Diagnostics
The -d flag prints debugging information to the terminal.