#include <stdlib.h>#include <stdio.h>Go to the source code of this file.
Defines | |
| #define | check_ptr(ptr, fn) |
Functions | |
| float ** | allocate_2d_float (int N, int M, char zero) |
| void | free_2d_float (float **a, int N) |
| int ** | allocate_2d_int (int N, int M, char zero) |
| void | free_2d_int (int **a, int N) |
| FILE * | myfopen (char *str, char *fmt) |
| float ** | load_image (char *name, int N1, int N2) |
| void | save_image (char *name, float **im, int N1, int N2) |
|
|
Value: if((ptr)==NULL) { \
printf("%10s: NULL pointer\n",(char *)(fn)); \
perror((char *)(fn)); \
exit(1); \
}Definition at line 8 of file support_routines.c. Referenced by allocate_2d_float, allocate_2d_int, and myfopen. |
|
||||||||||||||||
|
Definition at line 16 of file support_routines.c. References check_ptr.
00018 {
00019 int i;
00020 float **mymat;
00021
00022 mymat=(float **)malloc(N*sizeof(float *));
00023 check_ptr(mymat,"allocate_2d_float");
00024 if(!zero) {
00025 for(i=0;i<N;i++) {
00026
00027 mymat[i]=(float *)malloc(M*sizeof(float));
00028 check_ptr(mymat[i],"allocate_2d_float");
00029 }
00030 }
00031 else {
00032 for(i=0;i<N;i++) {
00033
00034 mymat[i]=(float *)calloc(M,sizeof(float));
00035 check_ptr(mymat[i],"allocate_2d_float");
00036 }
00037 }
00038 return(mymat);
00039 }
|
|
||||||||||||||||
|
Definition at line 53 of file support_routines.c. References check_ptr.
00055 {
00056 int i;
00057 int **mymat;
00058
00059 mymat=(int **)malloc(N*sizeof(int *));
00060 check_ptr(mymat,"allocate_2d_int");
00061 if(!zero)
00062 for(i=0;i<N;i++) {
00063
00064 mymat[i]=(int *)malloc(M*sizeof(int));
00065 check_ptr(mymat[i],"allocate_2d_int");
00066 }
00067 else
00068 for(i=0;i<N;i++) {
00069
00070 mymat[i]=(int *)calloc(M,sizeof(int));
00071 check_ptr(mymat[i],"allocate_2d_int");
00072 }
00073 return(mymat);
00074 }
|
|
||||||||||||
|
Definition at line 41 of file support_routines.c.
00043 {
00044 int i;
00045
00046 for(i=0;i<N;i++) {
00047
00048 free((void *)a[i]);
00049 }
00050 free((void *)a);
00051 }
|
|
||||||||||||
|
Definition at line 76 of file support_routines.c.
00078 {
00079 int i;
00080
00081 for(i=0;i<N;i++) {
00082
00083 free((void *)a[i]);
00084 }
00085 free((void *)a);
00086 }
|
|
||||||||||||||||
|
Definition at line 98 of file support_routines.c. References allocate_2d_float, and myfopen.
00100 {
00101 int i,j;
00102 float **res;
00103 FILE *mf;
00104
00105 res=allocate_2d_float(N1,N2,0);
00106 mf=myfopen(name,"rb");
00107 for(i=0;i<N1;i++) {
00108
00109 for(j=0;j<N2;j++) {
00110
00111 if(feof(mf)) {
00112
00113 printf("eof reached in loading %4d x%4d image\n",N1,N2);
00114 printf("at row %d and column %d\n",i,j);
00115 printf("perhaps you have the dimensions wrong?\n");
00116 exit(1);
00117 }
00118 else
00119 res[i][j]=(float)fgetc(mf);
00120 }
00121 }
00122 fclose(mf);
00123 return(res);
00124 }
|
|
||||||||||||
|
Definition at line 88 of file support_routines.c. References check_ptr.
00090 {
00091 FILE *res;
00092
00093 res=fopen(str,fmt);
00094 check_ptr(res,"myfopen");
00095 return(res);
00096 }
|
|
||||||||||||||||||||
|
Definition at line 126 of file support_routines.c. References myfopen.
00128 {
00129 int i,j;
00130 FILE *mf;
00131
00132 mf=myfopen(name,"wb");
00133 for(i=0;i<N1;i++) {
00134
00135 for(j=0;j<N2;j++) {
00136
00137 fputc((int)im[i][j],mf);
00138 }
00139 }
00140 fclose(mf);
00141 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002