hi,
i got a problem with this program, the compilation happens without problem but when i execute him, i allways get a segmentation fault (core dumped).
i dont know anymore what to do so if somobody could help me, i thank him very mush by advance
here is the code :
% more training.c
#include <stdio.h>
#define BANDS 21
main(int argc, char *argv[])
{
typedef unsigned char Pixel;
int rows = 2500;
int cols = 3500;
int scansize = 100000;
int classes = 39;
int bands = BANDS;
long nrpixels;
int i, j,k;
int cellvalue;
int nrscans;
int remainder;
char *filelist[BANDS] = { "eum12.bin","eum13.bin","eum14.b
in","eum22.bin","eum23.bin","eum24.bin","eum32.bin","eum33.bin","eum34.bin","eum
42.bin","eum43.bin","eum44.bin","eum52.bin","eum53.bin","eum54.bin","eum62.bin",
"eum63.bin","eum64.bin","bos3.blk","herby3.blk","bare3.blk" };
Pixel scanlijn [BANDS][100000];
FILE *ifp[BANDS], *samples;
nrpixels = rows * cols;
remainder = nrpixels % scansize;
nrscans = (nrpixels - remainder) / scansize;
for (i = 0 ; i < bands ; i++) {
if ((ifp = fopen(filelist, "rb") == NULL)
printf ("File could not be opened!\n"
}
if ((samples = fopen("recusepix3.blk", "rb") == NULL)
printf ("File could not be opened!\n"
for (i = 0 ; i < nrscans ; i++) {
for (j = 1 ; j <= bands ; j++)
fread(scanlijn[j], sizeof (Pixel), scansize, ifp[j-1]);
fread (scanlijn[0], sizeof(Pixel), scansize, samples);
for (j=0 ; j < scansize ; j++) {
if (scanlijn[0][j] != 0) {
for (k = 0 ; k <= bands ; k++)
printf ("%d\t" , scanlijn[k][j]);
printf ("\n"
}
//printf ("%d\t%d\t%d\t%d\t%d\t%d\t%d\n"
, scanlijn[0][j], scanlijn[1][j], scanlijn[2][j], scanlijn[3][j],scanlijn[4][j],
scanlijn[5][j], scanlijn[6][j]);
}
}
for (j = 1 ; j <= bands ; j++)
fread (scanlijn[j], sizeof(Pixel), remainder, ifp[j-1]);
fread (scanlijn[0], sizeof(Pixel), remainder, samples);
for (j=0 ; j < remainder ; j++) {
if (scanlijn[0][j] != 0) {
for (k = 0 ; k <= bands ; k++)
printf ("%d\t" , scanlijn[k][j]);
printf ("\n"
}
//printf ("%d\t%d\t%d\t%d\t%d\t%d\t%d\n"
, scanlijn[0][j], scanlijn[1][j], scanlijn[2][j], scanlijn[3][j],scanlijn[4][j],
scanlijn[5][j],scanlijn[6][j]);
}
}
%
Maxime Grondel
Belgium
i got a problem with this program, the compilation happens without problem but when i execute him, i allways get a segmentation fault (core dumped).
i dont know anymore what to do so if somobody could help me, i thank him very mush by advance
here is the code :
% more training.c
#include <stdio.h>
#define BANDS 21
main(int argc, char *argv[])
{
typedef unsigned char Pixel;
int rows = 2500;
int cols = 3500;
int scansize = 100000;
int classes = 39;
int bands = BANDS;
long nrpixels;
int i, j,k;
int cellvalue;
int nrscans;
int remainder;
char *filelist[BANDS] = { "eum12.bin","eum13.bin","eum14.b
in","eum22.bin","eum23.bin","eum24.bin","eum32.bin","eum33.bin","eum34.bin","eum
42.bin","eum43.bin","eum44.bin","eum52.bin","eum53.bin","eum54.bin","eum62.bin",
"eum63.bin","eum64.bin","bos3.blk","herby3.blk","bare3.blk" };
Pixel scanlijn [BANDS][100000];
FILE *ifp[BANDS], *samples;
nrpixels = rows * cols;
remainder = nrpixels % scansize;
nrscans = (nrpixels - remainder) / scansize;
for (i = 0 ; i < bands ; i++) {
if ((ifp = fopen(filelist, "rb") == NULL)
printf ("File could not be opened!\n"
}
if ((samples = fopen("recusepix3.blk", "rb") == NULL)
printf ("File could not be opened!\n"
for (i = 0 ; i < nrscans ; i++) {
for (j = 1 ; j <= bands ; j++)
fread(scanlijn[j], sizeof (Pixel), scansize, ifp[j-1]);
fread (scanlijn[0], sizeof(Pixel), scansize, samples);
for (j=0 ; j < scansize ; j++) {
if (scanlijn[0][j] != 0) {
for (k = 0 ; k <= bands ; k++)
printf ("%d\t" , scanlijn[k][j]);
printf ("\n"
}
//printf ("%d\t%d\t%d\t%d\t%d\t%d\t%d\n"
, scanlijn[0][j], scanlijn[1][j], scanlijn[2][j], scanlijn[3][j],scanlijn[4][j],
scanlijn[5][j], scanlijn[6][j]);
}
}
for (j = 1 ; j <= bands ; j++)
fread (scanlijn[j], sizeof(Pixel), remainder, ifp[j-1]);
fread (scanlijn[0], sizeof(Pixel), remainder, samples);
for (j=0 ; j < remainder ; j++) {
if (scanlijn[0][j] != 0) {
for (k = 0 ; k <= bands ; k++)
printf ("%d\t" , scanlijn[k][j]);
printf ("\n"
}
//printf ("%d\t%d\t%d\t%d\t%d\t%d\t%d\n"
, scanlijn[0][j], scanlijn[1][j], scanlijn[2][j], scanlijn[3][j],scanlijn[4][j],
scanlijn[5][j],scanlijn[6][j]);
}
}
%
Maxime Grondel
Belgium