Включите предупреждения компилятора и прочитайте их.Они там, чтобы помочь.Вот что я получил при компиляции:
$ gcc main.c
main.c: In function ‘thresh’:
main.c:10:23: warning: comparison between pointer and integer
if (im[i] > t)
^
main.c: In function ‘main’:
main.c:24:12: warning: passing argument 1 of ‘thresh’ from incompatible pointer type [-Wincompatible-pointer-types]
thresh((float*)im, (float*)im2, th, 2);
^
main.c:4:5: note: expected ‘double **’ but argument is of type ‘float *’
int thresh(double *im[], double *im2[], int t, int m)
^~~~~~
main.c:24:24: warning: passing argument 2 of ‘thresh’ from incompatible pointer type [-Wincompatible-pointer-types]
thresh((float*)im, (float*)im2, th, 2);
^
main.c:4:5: note: expected ‘double **’ but argument is of type ‘float *’
int thresh(double *im[], double *im2[], int t, int m)
^~~~~~
Итак, есть некоторые вещи, которые нужно исправить.
Прежде всего, прототип для thresh
должен быть int thresh(double *im, double *im2, int t, int m)
или даже лучше int thresh(const double *im, double *im2, int t, int m)
Во-вторых, почему вы смешиваете float
и double
?Придерживайтесь одного и придерживайтесь double
, если у вас нет действительно веской причины.