/* Shrink: This routine shrinks the floating point image pointed to by inbuf to the short integer image pointed to by outbuf. The image inbuf is assumed to be length pixels. Written by Sandor L. Barna, December 1993. */ #include <string.h> #include <stdio.h> #include <stdlib.h> void shrink(float *inbuf,unsigned short *outbuf,int length,int pedestal) { int i; int low_end, *i_data; unsigned short int i2_data[2]; i_data = (int *)&i2_data[0]; *i_data = 1; if (i2_data[0] == 0) low_end = 1; else low_end = 0; for (i=0;i<length;i++) { *i_data = inbuf[i] + 0.5; if (*i_data <= 0) *i_data = pedestal; outbuf[i]=i2_data[low_end]; } return; }