Some handy shell scripts: 1) You can open headerless raw images in xv directly using a simple 1 line shell script. Of course you would need to know the image dimensions: create a file named: xh containing the following one line code: echo $1 $2 $3 255 | cat - $4 | xv - Change file permission to make it executable by the shell: chmod 755 xh; To view a grayscale raw image file (8 bit raster scan) which has no header, type the following at the command prompt: xh P5 column_size row_size file_name for raw color image files (3*8 bit raster scan) use P6 instead of P5. 2) Again, you can easily add header information to a headerless raw image without having to open an editor or run C code. Simply create a file named: addhdr with the following 3 line code: echo $1 $2 $3 255 > $4.header cat $4 >> $4.header \mv $4.header $4 and at the command prompt type: addhdr P5 column_size row_size file_name WARNING: if there already exists a file called: file_name.header, it gets deleted. -------------------------------------------------------------------------------- % Matlab function to read in raw images: % In Matlab, the % symbol denotes a commented line function Image = read(filename,rows,columns) % Usage: Image = read(filename,rowsize,colsize); % % returns an integer array of intensity values of the image in % the specified file where the image is assumed to be saved in % 8 bit grayscale raw format with its xv header removed. % The read image is displayed for verification fid = fopen(filename,'r'); Image = fread(fid,[columns,rows],'uchar'); fclose(fid); Image = Image'; % Matlab reads data in column order %imshow(Image,[0,255]); % Display image -------------------------------------------------------------------------------- /* Interesting macro for rounding floats to integers */ #define round(x) ((int)((int)x + (int)(2*(x-(int)x)))) /* C code for representing, reading, and writing image data using 2-D arrays */ int **array, i,j, Rsize, Csize; /* i indexes rows, j indexes columns, Rsize = number of rows, Csize = number of columns */ /* allocate memory for 2-D array */ array = (int **)malloc(Rsize*sizeof(int *)); for(i=0;i