/* GrayPower.cpp * * Generate 256 level 8 x 1 grayscale */ #include #include #include "image.h" void GrayPower(IMAGE *out, double expon); const int LEVELS = 8; const int CELL_SIZE = 512 / LEVELS; int main(int argc, char *argv[]) { IMAGE *ip; char *filename; double expon; filename = "gray.img"; expon = 2.0; if (argc<2) printf("Usage: graypower filename expon\n"); if (argc>1) filename = argv[1]; if (argc>2) sscanf(argv[2],"%lf",&expon); ip = make_image(filename,LEVELS*CELL_SIZE,CELL_SIZE,PIX_BYTE); printf("filename: %s\n",filename); printf("image size: %d x %d\n",ip->hlen,ip->vlen); printf("power law exponent: %g\n",expon); GrayPower(ip, expon); return 0; } void GrayPower(IMAGE *out, double expon) { int i, j, k; pixel *buf, color; double dx = 1.0/(LEVELS-1); buf = make_buffer(out); for (i=k=0; ivlen; j++) { put_line(out,j,buf,PIX_BYTE); } free_buffer(buf); }